使用 oauth2 和日历 Api v3 Java 将事件更新为 google 日历
Update Event to google calendar using oauth2 and calendar Api v3 Java
使用 oauth2 和日历 Api v3 将事件更新为 google 日历。但我找不到任何例子。
我有这样的插入并阅读所有事件
Event event = new Event();
event.setSummary("My Event");
event.setLocation("My 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 = service.events().insert("primary", event)
.execute();
System.out.println("Created My Event id: " + createdEvent.getId());
但是我有活动更新?
工作感谢给予link @DalmTo
import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.Event;
// ...
// Initialize Calendar service with valid OAuth credentials
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
.setApplicationName("applicationName").build();
// Retrieve the event from the API
Event event = service.events().get("primary", "eventId").execute();
// Make a change
event.setSummary("Appointment at Somewhere");
// Update the event
Event updatedEvent = service.events().update("primary", event.getId(), event).execute();
System.out.println(updatedEvent.getUpdated());
使用 oauth2 和日历 Api v3 将事件更新为 google 日历。但我找不到任何例子。 我有这样的插入并阅读所有事件
Event event = new Event();
event.setSummary("My Event");
event.setLocation("My 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 = service.events().insert("primary", event)
.execute();
System.out.println("Created My Event id: " + createdEvent.getId());
但是我有活动更新?
工作感谢给予link @DalmTo
import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.Event;
// ...
// Initialize Calendar service with valid OAuth credentials
Calendar service = new Calendar.Builder(httpTransport, jsonFactory, credentials)
.setApplicationName("applicationName").build();
// Retrieve the event from the API
Event event = service.events().get("primary", "eventId").execute();
// Make a change
event.setSummary("Appointment at Somewhere");
// Update the event
Event updatedEvent = service.events().update("primary", event.getId(), event).execute();
System.out.println(updatedEvent.getUpdated());