使用oauth2和日历Api v3 Java将事件更新为Google日历

时间:2016-01-27 11:40:45

标签: java google-calendar-api google-api-java-client

使用oauth2和日历Api v3将事件更新为Google日历。但我找不到任何例子。 我有这样插入并阅读所有事件

{{1}}

但我有更新事件吗?

1 个答案:

答案 0 :(得分:0)

Works Thanx给予链接@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());