Sameer Surjikar
Sameer Surjikar

Reputation: 521

All Event listing on specified date in Google Calender api (V3) in java?

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.

Upvotes: 1

Views: 4377

Answers (3)

Tequila
Tequila

Reputation: 864

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(); 

Upvotes: 3

Sameer Surjikar
Sameer Surjikar

Reputation: 521

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...

Upvotes: 8

Shadow
Shadow

Reputation: 6277

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.

Upvotes: 1

Related Questions