Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 谷歌日历API的问题;getTimes();方法_Java_Api_Gwt_Google Calendar Api - Fatal编程技术网

Java 谷歌日历API的问题;getTimes();方法

Java 谷歌日历API的问题;getTimes();方法,java,api,gwt,google-calendar-api,Java,Api,Gwt,Google Calendar Api,我试图从google calendar的JAVA API中获取一些信息。当我试图获取事件发生时间的信息时,我遇到了一个问题。我做了以下工作: CalendarService myService = new CalendarService("project_name"); myService.setUserCredentials("user", "pwd"); URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/p

我试图从google calendar的JAVA API中获取一些信息。当我试图获取事件发生时间的信息时,我遇到了一个问题。我做了以下工作:

CalendarService myService = new CalendarService("project_name");
myService.setUserCredentials("user", "pwd");
URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/private/full");
CalendarQuery q = new CalendarQuery(feedUrl);
CalendarEventFeed resultFeed = myService.query(q, CalendarEventFeed.class);
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
              CalendarEventEntry g = resultFeed.getEntries().get(i);
List<When> t = g.getTimes();
//other operations
}
CalendarService myService=newcalendarservice(“项目名称”);
setUserCredentials(“用户”、“pwd”);
URL feedUrl=新URL(“http://www.google.com/calendar/feeds/default/private/full");
CalendarQuery q=新的CalendarQuery(feedUrl);
CalendarEventFeed resultFeed=myService.query(q,CalendarEventFeed.class);
for(int i=0;i

在CalendarEventEntry上使用getTimes()获得的列表t总是空的,我不知道为什么。这对我来说似乎很奇怪,因为对于一个日历事件来说,它应该总是存在一个关于它应该发生的时间的描述。。。我错过了什么

您必须意识到或单次事件与重复事件:

getTimes
用于单个时间事件

对于定期事件,您必须使用
getRecurrence()

或者,您可以将
singleevents
属性设置为true,这样重复发生的事件将作为单个事件返回,而getTimes将返回一个非空列表:

CalendarQuery q = new CalendarQuery(feedUrl);
q.setStringCustomParameter("singleevents", "true");
CalendarEventFeed resultFeed = myService.query(q, CalendarEventFeed.class);
// process the results as single-events now...
参考:查找文本“singleevents”


注意:如果您使用magic cookie url访问提要,则无论您如何在查询中设置
singleevents
属性,重复事件始终作为重复事件返回。

您必须意识到或单时间事件与重复事件:

getTimes
用于单个时间事件

对于定期事件,您必须使用
getRecurrence()

或者,您可以将
singleevents
属性设置为true,这样重复发生的事件将作为单个事件返回,而getTimes将返回一个非空列表:

CalendarQuery q = new CalendarQuery(feedUrl);
q.setStringCustomParameter("singleevents", "true");
CalendarEventFeed resultFeed = myService.query(q, CalendarEventFeed.class);
// process the results as single-events now...
参考:查找文本“singleevents”

注意:如果您使用magic cookie url访问提要,则无论您在查询中如何设置
singleevents
属性,重复事件始终作为重复事件返回。

(提供了相同的答案,但有附加信息)

(提供了相同的答案,但有附加信息)