views:

38

answers:

1

Hey guys,

I'm relatively new to Java, so I have little to no idea where to even start with this one. I'm writing a scheduling application using Java and google calendars. On my google account I have a bunch of calendars with people's schedules on them. I need to access these calendars through java and insert the person's free / busy information into arrays like so:

    //User 1
    int[][] swift_schedule = new int[5][6];
    //1 = busy, 0 = free

    //Monday
    swift_schedule[0][0] = 0;  //9-11
    swift_schedule[0][1] = 1;  //11-1
    swift_schedule[0][2] = 1;  //1-3
    swift_schedule[0][3] = 1;  //3-5
    swift_schedule[0][4] = 1;  //5-7
    swift_schedule[0][5] = 1;  //7-9
    //Tuesday
    swift_schedule[1][0] = 0; //9-11
    swift_schedule[1][1] = 0; //11-1
    swift_schedule[1][2] = 0; //1-3

    etc....

If I were using PHP, I would get a url for the XML feed and just parse the data out of it, but with JAVA I don't even know where to start. Can anyone point me in the right direction? Tutorials, code snippets, and other hints would be greatly appreciated!

cheers,
Mike

+3  A: 

You don't have to do the parsing when there is a Java API for it, simply use it and query for the calendar events you want.

With DateTime and CalendarQuery you can query for events in a specific time interval (your use case: to get events in a give day).

CalendarQuery myQuery = new CalendarQuery(feedUrl);
myQuery.setMinimumStartTime(DateTime.parseDateTime("2006-03-16T00:00:00"));
myQuery.setMaximumStartTime(DateTime.parseDateTime("2006-03-24T23:59:59"));

Google Calendar allows client applications to view and update calendar events in the form of Google Data API feeds. Your client application can use the Google Calendar Data API to create new events, edit or delete existing events, and query for events that match particular criteria.

Bakkal
Gotcha, that makes life a lot easier. Any idea where I can find some up to date instructions on getting it to work with eclipse on Windows? Everything I've found is either written for linux or is out dated.
Mike