-
Notifications
You must be signed in to change notification settings - Fork 36
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
java.time.Instant is not good fit for date-time-iso8601 representation #520
Comments
Hey, What you explain makes 100% sense. If there is currently an issue where all readers aren't compatible with all writers, we should fix that as soon as possible. I am not sure about the plumbing, stepped away from API Builder recently, but Gregor should have all the context related to using |
Yeah, that's a good point and was an oversight when we implemented the http4s generator. I guess the assumption was that datetime values are always serialized in Zulu time (eg Changing the generators to de/serialize OffsetDateTime instead of Instant would obviously be a breaking change wrt the generated code, so we should be careful making this change and only enable it via a generator attribute, but we can certainly fix the deserialization of date times with offsets into Instant via |
Fixed offset date time parsing in #525 |
In preparation to a fix that allows generating OffsetDateTime instead of Instant via a generator attribute, all de/serialization had to be consolidated in one place. See #526 |
Currently
java.time.Instant
is used to represent date time (date-time-iso8601
) forPlay 2.6 (Gen 2)
andhttp4s
generators.The problem is that
java.time.Instant
represents local time only and is not aware of timezone and hence can only support time in UTC. Therefore the only date time format it supports is the one ending withZ
(e.g.2019-04-04T14:16:23Z
). While other valid ISO 8601 date times formats are not supported e.g.:2019-04-04T14:16:23+00:00
2019-04-04T14:16:23+01:00
ZonedDateTime
seems to be a better fit:So when currently Play 2.6 (Gen 1) service exposes date time in non-UTC (as
"2019-04-04T14:16:23-05:00"
) then Http4s / Play 2.6 Gen 2 client is unable to deserialize json payload (expectingInstant
as<datetime>Z
).Reference:
https://en.wikipedia.org/wiki/ISO_8601
https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators
Please share your thoughts.
CC: @gheine @plippe
The text was updated successfully, but these errors were encountered: