This constructor uses the Calendar class to remove the time components from the specified date. The Calendar object returned from Calendar.getInstance defaults to using the default timezone for the device (machine). This causes the resulting date to be offset by the default timezone’s offset from UTC. As an example:
I want to create an all day event with a start date of 9/24/2015 and end date of 9/25/2015. I pass in a date object for 9/24/2015 00:00:00, and 9/25/2015 00:00:00 (obviously UTC, since all Dates are UTC). My timezone is CDT (UTC-5:00). What happens is, the Calendar object has a time of 9/23/2015 19:00:00, because it’s in CDT time, and I end up with a date of 9/23/2015 with the time components removed.
This should be a simple matter of adding the line: c.setTimeZone(TimeZone.getTimeZone("UTC”));
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
When creating dates that don't have time components, always use the default timezone when creating the Date object.
There was a bug related to inproper casting. After the bug fix, I was able to successfully create a VEVENT that had start/end dates without time components. Please let me know if this still doesn't solve your issue.
View and moderate all "Help and Support" comments posted by this user
Mark all as spam, and block user from posting to "Discussion"
This constructor uses the Calendar class to remove the time components from the specified date. The Calendar object returned from Calendar.getInstance defaults to using the default timezone for the device (machine). This causes the resulting date to be offset by the default timezone’s offset from UTC. As an example:
I want to create an all day event with a start date of 9/24/2015 and end date of 9/25/2015. I pass in a date object for 9/24/2015 00:00:00, and 9/25/2015 00:00:00 (obviously UTC, since all Dates are UTC). My timezone is CDT (UTC-5:00). What happens is, the Calendar object has a time of 9/23/2015 19:00:00, because it’s in CDT time, and I end up with a date of 9/23/2015 with the time components removed.
This should be a simple matter of adding the line: c.setTimeZone(TimeZone.getTimeZone("UTC”));
Thanks of the report. Sorry for the late reply.
When creating dates that don't have time components, always use the default timezone when creating the Date object.
There was a bug related to inproper casting. After the bug fix, I was able to successfully create a VEVENT that had start/end dates without time components. Please let me know if this still doesn't solve your issue.
Produces:
Fixed in: b6b229e23d10ddd4c6cb123c202d813de34cb834