google Calendar API (Java)

妖精的绣舞 提交于 2020-01-25 18:14:14

问题


How to get the Date/time for an Event I retrieve ?

CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
myService.setUserCredentials("username@gmail.com", "pwd");
URL feedUrl = new URL("https://www.google.com/calendar/feeds/username@gmail.com/public/full");

CalendarQuery myQuery = new CalendarQuery(feedUrl);
myQuery.setFullTextQuery("Query");
CalendarEventFeed myResultsFeed = myService.query(myQuery,
    CalendarEventFeed.class);

  for (int i=0; i < myResultsFeed.getEntries().size(); i++)
  {
    CalendarEventEntry firstMatchEntry = (CalendarEventEntry) myResultsFeed.getEntries().get(i);
    String myEntryTitle = firstMatchEntry.getTitle().getPlainText();
    System.out.println(myEntryTitle + " " + firstMatchEntry.getPlainTextContent());
    System.out.println(""+firstMatchEntry.getAuthors().get(0).getEmail());
    System.out.println(""+firstMatchEntry.getPublished());
    System.out.println(""+firstMatchEntry.getHtmlLink().getHref());
    System.out.println(""+firstMatchEntry.getStatus().getValue());
  }

I couldn't find a way to get any more useful info from a CalendarEventEntry.

LE: problem solved; after seeing this:

http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html#RetrievingEvents

I got to this:

System.out.println("start time = "+firstMatchEntry.getTimes().get(0).getStartTime());
System.out.println("start time = "+firstMatchEntry.getTimes().get(0).getEndTime());

Good thing the examples are different depending on language.


回答1:


Problem solved; after seeing this:

http://code.google.com/apis/calendar/data/1.0/developers_guide_php.html#RetrievingEvents

I got to this:

System.out.println("start time = "+firstMatchEntry.getTimes().get(0).getStartTime());
System.out.println("start time = "+firstMatchEntry.getTimes().get(0).getEndTime());


来源:https://stackoverflow.com/questions/6995495/google-calendar-api-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!