簡體   English   中英

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

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

我試圖確定登錄用戶在給定時間是否空閑。 到目前為止,我已經使用此代碼獲得了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());

此打印

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

我只想要布爾值是/否響應(如果用戶忙)。

我在錯誤的上下文中使用FreeBusy嗎? 我是使用Google的API的新手,並且在Java中也相對較差,因此,如果答案很明顯,則表示歉意。

發送請求時req.setTimeMin(startTime); req.setTimeMax(結束時間); 到freebusy.query,如果您發送項目.id->,這是您要從中檢索忙/閑信息的日歷ID,那么在響應中,您將獲得“忙”:[{“開始”:日期時間, “ end”:datetime},表示日歷從上述日期的開始到您在響應中得到的結束日期都很忙。 但是您不會獲得任何對/錯的信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM