-
Notifications
You must be signed in to change notification settings - Fork 31
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
[BUGFIX] Correctly deserialize ISO 8601 string with timezone offset #44
Conversation
We are using this in production in a project and I'd like to fix it there. Could you please release 1.7.1 after merging this pull request? Thanks in advance! |
@sgrossberndt I should have it released in the next 18 hours. |
@sgrossberndt And thanks for the fix. |
@sgrossberndt I had hoped to release this for you, but I get unit test failures running the build after the change.
The non-obvious thing about the failure, is that (by the
...so I take it there is some other aspect of the I don't have time to dig into this at the moment unfortunately. Do you get the test failures? (The tests pass if I back out your change). |
@sgrossberndt It looks like they end up with different
yields:
and if the Chronologies are different, the Would you be able to see if you can find out what the right thing to do here is. These days I am more familiar with the |
@sgrossberndt any luck? |
You're welcome. Thanks for the merge.
In the serialized string only the timezone value is saved (not the name) - so the behaviour of losing the timezone name is to be expected. This was the case before too - its just visible now as before the reconstructed DateTime always was UTC. Mapping back to the named timezone is not trivial as in most cases there are several named timezones with the same value. One option would be to serialize the timezone name too, but that is potentially breaking. Other (de)serializers have the same problem: As Java 8 DateTime do not seem to suffer from that I wonder if it is worth the hassle to fix this. Of course with this the roundtrip is "broken", one option would be to use a UTC DateTime in that test. |
@sgrossberndt: |
Thank you very much! |
When unserializing a ISO 8601 string with timezone offset like
2019-01-31T10:37:20.631+01:00
using theDateTimeConverter
it currently gets converted to UTC2019-01-31T09:37:20.631Z
. In order to re-instatiate the DateTime object as it was passed to Gson the offset has to be parsed.