[英]How to create new event in Google Calendar API with java in NetBeans
我遵循了Google在Calendar API上提供的快速入門指南https://developers.google.com/google-apps/calendar/quickstart/java,但他們沒有解釋如何創建新事件。 我在網上找到了這段代碼
public void createEvent(Calendar cal){
Event event = new Event();
event.setSummary("Event name here");
event.setLocation("event place here");
Date startDate = new Date();
Date endDate = new Date(startDate.getTime() + 3600000);
DateTime start = new DateTime(startDate, TimeZone.getTimeZone("UTC"));
event.setStart(new EventDateTime().setDateTime(start));
DateTime end = new DateTime(endDate, TimeZone.getTimeZone("UTC"));
event.setEnd(new EventDateTime().setDateTime(end));
Event createdEvent = cal.events().insert("primary", event).execute();
System.out.println("Created event id: " + createdEvent.getId());
}
但這對我沒有幫助,因為events()不存在,所以在event createdEvent = cal.events()部分出現了錯誤。 非常感謝您的任何幫助,謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.