-
-
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
Regression: DateConversionError in 2.6.x (2.5.4 works fine) #939
Comments
First of all, thank you for reporting possible issue. Unfortunately I can not yet reproduce the issue, after fixing a small issue with test: it seems to have an extra space before String date value. But I suspect this is because my default TimeZone (PST) differs from what you have, and that keeps actual date serialization the same. I can not yet determine whether there is a bug or not; the problem is with lack of time-zone information with So I will try to dig bit deeper to understand where exactly timezone changes. There are things you can do to work around the issue. Specifically, I think that setting |
Thank you very, very much for your fast answer! Actually you're right, of course it is about the timezone... I've updated my test case at https://github.com/anpieber/jackson-regression accordingly. Using format.setTimeZone(TimeZone.getTimeZone("UTC")); works like a charm while using format.setTimeZone(TimeZone.getTimeZone("Europe/Vienna")); fails. While your explanation does make perfect sense, and the workaround is quite simple, I still think that this is not the behavior most ppl are expecting. Especially since the behavior for this changed in a regular minor release. Kind regards, |
I agree this is not ideal, and I hope to see what causes it. So thank you for reporting the difference. |
Actually, thinking about this more, I am not sure this is a bug. The problem is this: You can see this for example by printing date using |
Actually I'm with you and we're feeling for quite some time now that we really should change all dates transmitted in JSON to a format including the timezone... Independently, I think the text put into Jackson should come out afterwards again; especially if the same converter is/should be used both times. Shouldn't jackson simply use the provided format instead of tostring for the date? Wouldn't this solve the problem? |
@anpieber Hmmh. Jackson should boe not using Not related to this, it may make sense to use Joda library's |
One minor comment on test methods: |
Ah ha! I found the issue; on serialization side, formatter's |
Hey, Thank you very, very much! Just some comments to the commit referenced in this issue.
Ad your comment at conversationOfTextToDateAndBackShouldWorkForViennaTimezone: those tests work as expected; only the notWorkingDateTest was failing. Ad Joda: We're already using Joda for most parts; there're just "some" legacy parts of the application still dependent on Date... |
@anpieber Sorry about typo for your last name! On unit tests: yes, ideally. Will try to add something; will just need to ensure a fair test wrt setting default |
If you try to convert a Date into a String it reduces it by one (while this works in 2.5.4). If you try to convert 2015-01-02 Date to String it prints out 2015-01-01. This bug is kind of critical I assume. I've created the most primitive test case showing the problem: https://github.com/anpieber/jackson-regression . If you downgrade the version to 2.5.4 in the pom you'll see that it works there (test is green).
The text was updated successfully, but these errors were encountered: