-
Notifications
You must be signed in to change notification settings - Fork 82
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
Change in timezone handling for Date created from Joda DateTime between 2.6.2 and 2.6.3 #76
Comments
I think this is related to #12 which says that Joda and JSR310 don't support mapper.setDateFormat whereas it's supported for java.util.Date |
I suppose your Since your ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss ZZZ"));
DateTime dateTime = new DateTime(1988, 6, 25, 20, 30, DateTimeZone.UTC);
Date date = dateTime.toDate(); // this is your local time zone
System.out.println(objectMapper.writeValueAsString(date)); |
I don't know what could cause this, but I thought I remember one particular fix that might be relevant: one where the default timezone initialized and used varied between reading (deser) and writing (ser). But I can not find an issue at this point, or specific commit... so that's bit odd. Anyway: one thing to double-check, just to be sure, is that 2.6.3 is used both for databind and joda module. I assume this is the case, but just want to be absolutely sure here. It seems to be the code sample here is correct, and behavior not, so definitely looks like a bug. But I do want to isolate it. |
@cowtowncoder I suppose the code uses the default |
@islanderman So maybe there is no way to actually retain it. There is just the question of which timezone should be used, for given configuration, when serializing |
@cowtowncoder I can confirm that the version of every Jackson module was the same |
Any progress on this? We're probably going to need to stick to Jackson 2.6.1 for Spring Boot 1.3.0. |
@philwebb Haven't had time to look into this, but I'll try to see what goes on here. As has been mentioned, Joda module doesn't seem involved at all because it's all about serializing |
@philwebb Ok, now I now know what is happening here, and why the change occurs. I think the trigger is the fix in 2.6.3 for: FasterXML/jackson-databind#939 which stops This can not really be fixed by
So where does the issue come from? Basically, In the past, Jackson did force mapper's timezone on Long story short: at this point it is best to explicitly set Hope this helps! |
@cowtowncoder Perfect! Thanks for the analysis. We can set the TimeZone on our side when we create the Have a good weekend 👍 |
@philwebb No problem, thank you for following up. This is a problematic area but hopefully gets eventually cleared up. |
In 2.6.3, I'm seeing a DateTime that's in UTC move into BST (my timezone) when it's converted into a Date and written as a String. In 2.6.1 and 2.6.2 it stays in UTC. This code reproduces the problem:
The output for various versions of Jackson:
2.6.1
2.6.2
2.6.3
(originally raised by @wilkinsona in FasterXML/jackson-databind#973)
The text was updated successfully, but these errors were encountered: