You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
applies a timezone from a default locale which leads to an incorrect result.
Input: 2019-03-20
Actual Output: 2019-03-19T23:00:00Z when a system default locale is UTC+01
Expected Output: 2019-03-20T00:00:00Z regardless of the system locale
I think the problem is that GregorianCalendar must be preconfigured with the UTC timezone, and it's not done in ISO8601Utils:
// if the value has no time component (and no time zone), we are done
boolean hasT = checkOffset(date, offset, 'T');
if (!hasT && (date.length() <= offset)) {
Calendar calendar = new GregorianCalendar(year, month - 1, day);
pos.setIndex(offset);
return calendar.getTime();
}
The text was updated successfully, but these errors were encountered:
It's certainly regrettable that the code is the way it is, but as I mentioned in #2480 we can't change it without breaking existing deployments. It's an internal class, so really I think what we're talking about is its use in DateTypeAdapter and DefaultDateTypeAdapter. I think we should probably have a configuration option that causes Date to be serialized following ISO 8601, and that might also imply that a deserialized date/time without a timezone defaults to UTC.
Parsing a "yyyy-MM-dd" date without a timezone using
applies a timezone from a default locale which leads to an incorrect result.
Input:
2019-03-20
Actual Output:
2019-03-19T23:00:00Z
when a system default locale is UTC+01Expected Output:
2019-03-20T00:00:00Z
regardless of the system localeI think the problem is that
GregorianCalendar
must be preconfigured with the UTC timezone, and it's not done inISO8601Utils
:The text was updated successfully, but these errors were encountered: