We have the problem, that we are receiving a time object definded in local time - with DST. Now we store the receive-time in the database as a DST-less timezone. Once in a year we have one hour where the conversion in not correct: at 2:00AM the clock will be set to 1:00AM in the incoming DST timezone (switching time to winter-time). We correct that to 2AM in local time (i.e. GMT). At 2:15AM we receive a packet which we correct again to 2:15. But now its really 2:15 and not 1:15. In principle we have doubled hour in the system now. The java gregorian calendar is not able to convert between timezones with accounting the current local tim (to determine if it must account for the doubled hour).
Here is my code to convert the incoming DST timezone to the non-DST one:
public static GregorianCalendar getCal(XMLGregorianCalendar c)
{
GregorianCalendar toGregorianCalendar = c.toGregorianCalendar();
TimeZone tz = TimeZone.getTimeZone("GMT+1");
toGregorianCalendar.setTimeZone(tz);
toGregorianCalendar.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
return toGregorianCalendar;
}
This seems to work ok for all the year - except the onle hour switching back to winter-time... Any idea about this mind bending problem?