Hi
I'm playing around with the Calender Java API, but I'm unable to
extract times from my calendar entries. I can see my entries, I'm able
to sort them and I get Title and content as plain text.
The code is shown below, where I have replaced the feed URL and user
credentials with "...".
The program should get all calendar entries in may 2007 and print the
results.
URL feedUrl;
GoogleService myService = new GoogleService("cl", "bhj-FamCalApp-1");
try {
//get feed and set user credencials here
feedUrl = new URL(...);
myService.setUserCredentials("...", "...");
CalendarQuery myQuery = new CalendarQuery(feedUrl);
String str_start = "2007-05-01T00:00:00";
String str_end = "2007-05-31T23:59:59";
myQuery.setMinimumStartTime(DateTime.parseDateTime(str_start));
myQuery.setMaximumStartTime(DateTime.parseDateTime(str_end));
myQuery.addCustomParameter(new Query.CustomParameter("orderby",
"starttime"));
myQuery.addCustomParameter(new Query.CustomParameter("sortorder",
"ascending"));
myQuery.addCustomParameter(new Query.CustomParameter(
"singleevents", "true"));
Feed resultFeed = (Feed) myService.query(myQuery, Feed.class);
new EventFeed().declareExtensions(myService.getExtensionProfile());
EventFeed calFeed = (EventFeed) myService.query(myQuery,
EventFeed.class);
EventEntry calEntry = null;
if (calFeed.getEntries().size() > 0) {
java.util.List lTimes = null;
java.util.List lLocs = null;
for (int n = 0; n < calFeed.getEntries().size(); n++) {
calEntry = (EventEntry) calFeed.getEntries().get(n);
// grabs description for event
TextContent tc = (TextContent) calEntry.getContent();
PlainTextConstruct ptc = (PlainTextConstruct) tc
.getContent();
String title = calEntry.getTitle().getPlainText();
System.out.println(title);
lTimes = calEntry.getTimes();
When when = null;
for (java.util.Iterator iterator1 = lTimes.iterator();
iterator1
.hasNext();) {
when = (When) iterator1.next();
String strTempStart =
when.getStartTime().toUiString();
System.out.println(strTempStart);
strTempStart =
strTempStart.substring(strTempStart
.indexOf(" "),
strTempStart.length());
System.out.println(strTempStart);
String strTempEnd =
when.getEndTime().toUiString();
System.out.println(strTempEnd);
strTempEnd = strTempEnd.substring(strTempEnd
.indexOf(" "),
strTempEnd.length());
System.out.println(strTempEnd);
strTempEnd =
DateTime.parseDateTime(strTempEnd).toString();
System.out.println(strTempEnd);
}
lLocs = calEntry.getLocations();
for (java.util.Iterator iterator1 = lLocs.iterator();
iterator1
.hasNext();) {
Where where = (Where) iterator1.next();
String wString = where.getValueString();
System.out.println(wString);
}
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
It should be noted, that I'm adding entries to my calendar via Mozilla
Thunderbird, with the "Provider for Google Calendar" and "Lightning"
extensions.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---