I can create a timed event using the Java v3 Google Calendar API (as per the sample code on Google's website), but I need to create an all-day event.
I call the event's setStart() and setEnd(), i.e.
event.setStart(startEventDateTime);
event.setEnd(endEventDateTime);
These methods require and EventDateTime, i.e.
EventDateTime startEventDateTime = new EventDateTime().setDateTime(startDateTime);
EventDateTime endEventDateTime = new EventDateTime().setDateTime(endDateTime);
I use the setDateTime() methods as setDate() causes a 404 error.
setDateTime() requires a com.google.api.client.util.DateTime object, by doing
DateTime startDateTime = new DateTime(startDate, TimeZone.getTimeZone("UTC"));
DateTime endDateTime = new DateTime(endDate, TimeZone.getTimeZone("UTC"));
Passing in the TimeZone gives a time element so it's not an all day event.
I've tried setting dateOnly to true but this gives an error:
DateTime startDateTime = new DateTime(true, startDate.getTime(), 0);
I can't get the other ways of creating DateTime to work: Date date, TimeZone zone long value Date value long value, Integer tzShift String value
Which way do I create DateTime and can I use setDate(), i.e. new EventDateTime().setDate(...)?
Does anyone have a tested code snippet? Why isn't this documented by Google?
ps Interestingly, when reading events from Google, using getDate() causes an exception with timed events and getDateTime() an exception with all-day events. Need to use getDate() for all-day events and getDateTime() for timed events.