Skip to content Skip to sidebar Skip to footer

Get Google Calendar Events Start And End Times With Google-java-api-client In Android

How would one go about parsing the start and end times of events in a users Google Calendar using the google-api-java-client? After installing this sample android project from Goog

Solution 1:

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;

Post a Comment for "Get Google Calendar Events Start And End Times With Google-java-api-client In Android"