I’m trying to get several informations from google calendar’s API in JAVA. While trying to access to informations about the time of an event I got a problem. I do the following:
CalendarService myService = new CalendarService("project_name");
myService.setUserCredentials("user", "pwd");
URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/private/full");
CalendarQuery q = new CalendarQuery(feedUrl);
CalendarEventFeed resultFeed = myService.query(q, CalendarEventFeed.class);
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
CalendarEventEntry g = resultFeed.getEntries().get(i);
List<When> t = g.getTimes();
//other operations
}
The list t obtained with getTimes() on a CalendarEventEntry is always empty and I can’t figure out why. This seems strange to me since for a calendar event it should always exist a description of when it should happen… what am I missing??
You have to be aware or single time events vs recurring events:
getTimesis used for single time events.For recurring events you have to use
getRecurrence()Or, you can set the
singleeventsproperty to true, so recurring events are returned as single events and getTimes will return a non-empty list:Reference: look for the text "singleevents" here.
Note: if you use a magic-cookie url to access the feed, then recurring events are always returned as recurring events, no matter how you set the
singleeventsproperty in the query.