简体   繁体   English

如何在Google Calendar Java API中使用FreeBusyResponse?

[英]How do I use the FreeBusyResponse in Google Calendar java API?

I'm trying to determine if the logged in user is free at a given time. 我试图确定登录用户在给定时间是否空闲。 So far I've managed to get a FreeBusyResponse, using this code. 到目前为止,我已经使用此代码获得了FreeBusyResponse。

String dIn = "2015-09-10 19:00:00";
String dIne = "2015-09-10 20:00:00";
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

Date d = df.parse(dIn);
DateTime startTime = new DateTime(d, TimeZone.getDefault());

Date de = df.parse(dIne);
DateTime endTime = new DateTime(de, TimeZone.getDefault())

FreeBusyRequest req = new FreeBusyRequest();
req.setTimeMin(startTime);
req.setTimeMax(endTime);
Freebusy.Query fbq = client.freebusy().query(req);

FreeBusyResponse fbresponse = fbq.execute();
System.out.println(fbresponse.toString());

This prints 此打印

{"kind":"calendar#freeBusy","timeMax":"2015-09-10T10:00:00.000Z","timeMin":"2015-09-10T09:00:00.000Z"}  

All I want is a boolean yes/no response for if the user is busy. 我只想要布尔值是/否响应(如果用户忙)。

Am I using FreeBusy in the wrong context? 我在错误的上下文中使用FreeBusy吗? I'm new to using google's APIs and still relatively noobish in Java as well, so apologies if the answer is obvious. 我是使用Google的API的新手,并且在Java中也相对较差,因此,如果答案很明显,则表示歉意。

While sending request req.setTimeMin(startTime); 发送请求时req.setTimeMin(startTime); req.setTimeMax(endTime); req.setTimeMax(结束时间); to freebusy.query, if you send items .id--> which is the calendar id from which you want to retreive the free/busy info, then in the response you will get "busy": [ { "start": datetime, "end": datetime } which indicates calendar is busy from starting above date to ending date you get in the response. 到freebusy.query,如果您发送项目.id->,这是您要从中检索忙/闲信息的日历ID,那么在响应中,您将获得“忙”:[{“开始”:日期时间, “ end”:datetime},表示日历从上述日期的开始到您在响应中得到的结束日期都很忙。 But you dont get any information in true/ false. 但是您不会获得任何对/错的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM