1

what I want to do is get all the events in a given google calendar for a given date.

Now we can get the event listing pretty easily using the following code

 public Events getAllEvent()
{
    Events events= null ;
    try {

        events = service.events().list(this.calendarID).execute();

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return events ;
}

How should I convert this function so that it will give only event on that day which i specify. I tried a lot of way but in version 3 it's not working the way it use to in v2. Any suggestion. Please Remeber that we are talking about google calender Api version 3.

John Conde
  • 217,595
  • 99
  • 455
  • 496
Sameer Surjikar
  • 511
  • 6
  • 12

3 Answers3

8

Hi ya i found the answer to my ques so updating here for others. This can be done. Though we do not have direct way we can do it using query parameter. Let say if we wanted events feed from today onwards and not earlier than today. Then we can do this.

Events events = service.events().list(calendarID).setTimeMin("2012-01-01T00:00:00Z").execute();

instead of

 events = service.events().list(this.calendarID).execute();

which just give us all the feeds from way back till 2031.

For getting feeds in between dates use setTimemin and setTimeMax together

Hope this help someone cheers...

Sameer Surjikar
  • 511
  • 6
  • 12
  • Hi Thanks for the answer, do you know how to set TimeMin in case of Objective-C (I mean for XCode, IOS development), since i can able to get the result when i am trying with Google APIs Explorer, but the same is giving error as "error": { "errors": [ { "domain": "global", "reason": "badRequest", "message": "Bad Request" } ], "code": 400, "message": "Bad Request" } } – sKhan Mar 17 '14 at 22:19
  • @ShafKhan - u might be sending in "global" or accessing the global list, instead change that to the "primary" list. – Rat-a-tat-a-tat Ratatouille May 27 '14 at 11:00
  • can you explain what does the T and Z in "2012-01-01T00:00:00Z" mean? – bubakazouba Apr 13 '15 at 02:38
3

Listed below is the code to use the Calendar service for v3 of the Google API utilizing Oauth2. I am posting it, since it is documented incorrectly by Google on their site.

Calendar service3 = new Calendar(transport, jsonFactory, accessProtectedResource);

com.google.api.services.calendar.model.Calendar calendar = service3.calendars().get("primary").execute();
com.google.api.services.calendar.model.Events events = service3.events().list("primary").execute(); 
Tequila
  • 844
  • 9
  • 19
1

Sameer currently the API doesn't includes this feature. But you can make a feature request here Apps Apis issue tracker.
You shall get some positive reply soon as it is monitored by Google engineers themselves.

Shadow
  • 6,161
  • 3
  • 20
  • 14