Get Google Calendar Events Start and End Times with google-java-api-client in Android

佐手、 提交于 2019-11-30 15:43:25

You'll need to use the EventFeed and take a look at the EventEntry class

http://code.google.com/p/google-api-java-client/source/browse/calendar-v2-atom-oauth-sample/src/com/google/api/client/sample/calendar/v2/model/EventEntry.java?repo=samples

The Atom string returned containing the startTime / endTime will look like this :

<gd:when startTime='2010-03-13T14:00Z' endTime='2010-03-13T14:30Z'/>

It's modelled in the EventEntry class like this :

@Key("gd:when")
public When when;

(a property for the When object, mapped using the @Key annotation)

The When object, models the start/endTime attributes on the When object

@Key("@startTime")
public DateTime startTime;

@Key("@endTime")
public DateTime endTime;

Client code when inteacting with the eventFeed will look like this :

EventEntry event = eventFeed.get(0);
DateTime start = event.when.startDate;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!