我尝试了很多方法来使用 oauth2 和 calendar Api v3 将事件插入到谷歌日历。但我找不到任何例子。
问问题
3188 次
1 回答
2
public void createEvent(Calendar cal) throws IOException {
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());
}
希望此代码段可能对您有所帮助
于 2013-04-10T04:52:41.173 回答