-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Gson serialize/deserialize rountrip of java.time.OffsetDateTime drops the time zone component #1526
Comments
After doing some research on this, I think I can summarize the root cause:
I thus, all the actual information does survive the round-trip, but the redundancy in I understand that it's too late to change gson's handling of serializing Is this something that should be done inside gson, or as a plugin? Would a PR with this functionality have any chance of being accepted? |
I tried it with a custom TypeAdapter: |
Please check this project. I have found the OffsetDateTime converter of theirs fully working and usefull |
The underlying issue here is that Gson does not have any built-in type adapters for the As mentioned in the comments above, prefer using a custom type adapter for the class. |
The following snippet illustrates the problem:
One run output the following:
Note that on the last line, after the serialization roundtrip, the timezone is dropped. Why? Is this a bug in gson, or a configuration error on my part?
This is with gson 2.8.5 and
The text was updated successfully, but these errors were encountered: