将 Java 与 Google 日历连接
我对 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 我不需要甚至不知道从哪里开始。有人能指出我正确的方向吗?教程、代码片段和其他提示将不胜感激!
干杯,
麦克风
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当有 Java API 时,您不必进行解析,只需使用它并查询您想要的日历事件即可。
使用 DateTime 和 CalendarQuery 您可以在以下位置查询事件特定的时间间隔(您的用例:获取给定日期的事件)。
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).