简体   繁体   中英

Get Current Time of CalendarEntry of Google Calendar API

I was wondering, is there anyway to get the current time of a CalendarEntry, of Google Calendar API.

I try to use the following hack :

       try {
            if (calendarEntry.getSummary().getPlainText().equalsIgnoreCase("XXX"))
            {
                calendarEntry.setSummary(new PlainTextConstruct("YYY"));
            }
            else
            {
                calendarEntry.setSummary(new PlainTextConstruct("XXX"));
            }

            calendarEntry = calendarEntry.update();
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ServiceException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

        // According to documentation, getUpdated shall returned CalendarEntry last 
        // update time.
        // Hopefully by explicitly modify the state of calendar, 
        // getUpdated will return latest time. 
        // Unfortunately, I find out the result is not always up-to-date. It will 
        // return pass time still.
        System.out.println("Calendar Entry = " + calendarEntry.getUpdated());

Getting NTP time from public time server is another option. However, I found out this doesn't meet my requirement, as it is quite time wasting, to make an extra query to another time server, instead of directly retrieve the information from Google itself.

也许从公共时间服务器获取NTP时间是唯一的选择。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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