-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ObjectMapper default timezone is GMT, should be UTC #915
Comments
Yes, the use of GMT is an old oversight, from the time when I did not realize that the two are not the same. The main concern at this point is simply whether change could cause backwards compatibility issues. For 2.6 I did try out to see how many unit tests would fail; the number was low (I think 2), and none seemed necessarily valid failure. But this is probably something that should still be discussed on |
Anyway it should definitely be synchronized with javadoc/documentation. I
|
Agreed. I would prefer move to UTC, as documented, but just wanted to point out the challenge. |
Changed for 2.7.0 so that default |
@cowtowncoder why not using java's default time zone? |
@cemo partly because use of local timezone is mostly an anti-pattern (that is, developers use it without realizing, causing issues). And this because similar to "default encoding" it is often somewhat arbitrary what the timezone might be. I guess this is just one argument in two parts... So, to me it is similar to "why default to UTF-8 instead of platform default encoding", although it is not exactly the same thing (because JSON mandates UTF-8 as default etc). |
Oh. And probably the bigger reason: since json is typically shared between two systems (sender/receiver) and those often have different default timezones, reliance on shared setting seems especially brittle. While timezone in use should be included in date/time values, and thereby setting should only affect serialization, it also seems likely that there are cases that would implicitly rely on shared setting, which could lead to nasty surprises (works during tests, fails in production). |
Thanks for great explanation. |
@cemo thank you for asking a good question: sometimes there are no good reasons, or reasons seem less convincing than what I thought. |
ObjectMapper is configured with GMT timezone:
(it's on line 280)
But on many places in documentation and even in javadoc it's written that it's configured with UTC timezone. It is even cleaner to use UTC.
The text was updated successfully, but these errors were encountered: