-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Support specifying TimeZone in Jackson2ObjectMapperFactoryBean [SPR-12594] #17195
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
Comments
Juergen Hoeller commented Specifically with the time zone setting, we should try to integrate it with the time zone management in Spring MVC, that is, the thread-local time zone - and only fall back to a globally configured time zone, analogous to our formatters. So this should probably be a 4.2-only change. Juergen |
Eric Rizzo commented While I understand the desire to align this with Spring MVC's timezone capability in 4.2, I don't understand why the 4.1 stream can't have this less-capable version rather than nothing at all. Not every app is going to wait for or update to 4.2 right away; seems like this is still better than nothing for those of us who need it right away and/or will be stuck on 4.1 for a while. Is there something in the Spring MVC stuff that makes it incompatible with this simple idea? |
Juergen Hoeller commented Alright, I don't mind it staying on the 4.1.x agenda. However, let's nevertheless consider the thread-local time zone scenario upfront and possibly implement it in 4.1.x as well. Juergen |
Juergen Hoeller commented If I follow Jackson's documentation right, it seems to default to GMT and not to the system time zone for JSON date processing. So Jackson's time zone setting seems to be more of an application-wide convention for JSON parsing, independent from general system configuration and custom user interface settings. The locale property on In contrast to that, the request-specific locale and time zone in Spring MVC is primarily a user interface setting. It seems like this doesn't fit here to begin with, since the JSON part of an application might rather want to consistently process dates in a configured time zone - and not allow the user to choose a specific date format per request like we do for user interfaces. As a consequence, let's not bother with specific MVC integration there yet (unless explicitly requested with a good use case at some later point). In summary, straightforward locale and time zone properties on Juergen |
Sébastien Deleuze commented Resolved on master by this commit + this one (I unintentionally used a Java 8 class in the first commit), ready to be backported on the 4.1.x branch. |
Juergen Hoeller commented A bit of fine-tuning during the backport, to be applied to master as well:
|
Eric Rizzo opened SPR-12594 and commented
Jackson2ObjectMapperFactoryBean should expose the timeZone property of ObjectMapper, to allow easily specifying a TimeZone to be used when parsing "plain" dates. Currently this can be done by extending Jackson2ObjectMapperFactoryBean and setting the ObjectMapper.setTimeZone() as it is being built, but that's awkward.
In general, Jackson2ObjectMapperFactoryBean should be consistent and expose all properties of ObjectMapper that an application might want to set.
Affects: 4.1.3
Issue Links:
Referenced from: commits 77fcf21, fab8dd3, bf7a975, b89e62e
The text was updated successfully, but these errors were encountered: