我对 Java 比较陌生,所以我几乎不知道从哪里开始。我正在使用 Java 和谷歌日历编写一个日程安排应用程序。在我的谷歌帐户上,我有一堆日历,上面有人们的日程安排。我需要通过 java 访问这些日历并将人员的空闲/忙碌信息插入到数组中,如下所示:
//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....
如果我使用 PHP,我会获取 XML feed 的 url,然后解析其中的数据,但使用 JAVA 我什至不知道从哪里开始。有人能指出我正确的方向吗?教程、代码片段和其他提示将不胜感激!
干杯,
迈克
最佳答案
当有 Java API 时,您不必进行解析,只需使用它并查询您想要的日历事件即可。
与 DateTime和 CalendarQuery您可以查询特定时间间隔内的事件(您的用例:获取给定日期的事件)。
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.
关于java - 将 Java 与 Google 日历连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3705989/