7 - leitmarkt-wettbewerb-createmedia.nrw
8 date: "2015-11-12T15:12:05+00:00"
9 guid: http://juplo.de/?p=554
12 title: How To Keep The Time-Zone When Deserializing A ZonedDateTime With Jackson
13 url: /how-to-keep-the-time-zone-when-deserializing-a-zoneddatetime-with-jackson/
16 ## The Problem: Jackson Loses The Time-Zone During Dezerialization Of A ZonedDateTime
18 In its default configuration [Jackson](http://wiki.fasterxml.com/JacksonHome "Visit the homepage of the Jackson-project") adjusts the time-zone of a `ZonedDateTime` to the time-zone of the local context.
19 As, by default, the time-zone of the local context is not set and has to be configured manually, Jackson adjusts the time-zone to GMT.
21 This behavior is very unintuitive and not well documented.
22 [It looks like Jackson just loses the time-zone during deserialization](http://stackoverflow.com/questions/19460004/jackson-loses-time-offset-from-dates-when-deserializing-to-jodatime/33674296 "Read this question on Stackoverflow for example") and, [if you serialize and deserialize a `ZonedDateTime`, the result will not equal the original instance](https://github.com/FasterXML/jackson-datatype-jsr310/issues/22 "See this issue on the jackson-datatype-jsr310 on GitHub"), because it has a different time-zone.
24 ## The Solution: Tell Jackson, Not To Adjust the Time-Zone
26 Fortunately, there is a quick and simple fix for this odd default-behavior: you just have to tell Jackson, not to adjust the time-zone.
27 Tis can be done with this line of code:
30 mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
33 ## Funded by the Europian Union
35 This article was published in the course of a
36 [resarch-project](http://yourshouter.com/projekte/crowdgest%C3%BCtzte-veranstaltungs-suchmaschine.html "Show details about the funded resarch-project"),
37 that is funded by the European Union and the federal state Northrhine-Wetphalia.
39 [](http://yourshouter.com/projekte/crowdgest%C3%BCtzte-veranstaltungs-suchmaschine.html "Show details about the funded resarch-project")