mangstadt / biweekly

biweekly is an iCalendar library written in Java.
BSD 2-Clause "Simplified" License
323 stars 44 forks source link

Bug in ICalDate(Date, DateTimeComponents, boolean) #13

Closed mangstadt closed 8 years ago

mangstadt commented 9 years ago

From thread: https://sourceforge.net/p/biweekly/discussion/help-and-support/thread/0540a0b1/?limit=25#e251

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”));

Reported by: mangstadt

Original Ticket: biweekly/tickets/13

mangstadt commented 9 years ago

Original comment by: mangstadt

mangstadt commented 9 years ago

Fixed in: b6b229e23d10ddd4c6cb123c202d813de34cb834

Original comment by: mangstadt