- changed status to open
Date Serialization Fails for TimeZones on Daylight Savings TIme
Issue #423
resolved
The following code is incorrect SafeRepresenter.java+392 in basically all releases since at least 1.19:
int gmtOffset = calendar.getTimeZone().getOffset(calendar.get(Calendar.ERA),
calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.DAY_OF_WEEK),
calendar.get(Calendar.MILLISECOND));
Because calendar.get(Calendar.MILLISECOND)
only returns the millisecond component of the time, not the number of milliseconds in the day, which is what is expected by the getOffset
method.
Either calculate the total number of milliseconds in the day and use that value, or use:
int gmtOffset = calendar.getTimeZone().getOffset(calendar.getTime().getTime());
See: Calendar.getOffset
This only occurs on the day that daylight savings occurs, so tomorrow it'll work fine, but today, broken.
Comments (3)
-
-
reporter Test case and fix are in pull request #42
-
- changed status to resolved
Thank you. It will be delivered in version 1.24
- Log in to comment
A test case might help to see the problem.