Open j-be opened 3 years ago
Hi @j-be , Thank you for reaching out. Unfortunately this behavior is by the spec. It is described which formatter should be used for each type if there is no formatter specified. For Date it is DateTimeFormatter.ISO_DATE_TIME
if there is any time information present. This can be found in 3.5.1 of the JSONB-API spec.
@Verdent Thanks for the feedback. I see. So following the spec the right thing to do would be to use java.time.OffsetDateTime
, is that correct?
After looking through it again - could it be that I (unknowingly) stumbled over a bug in Java itself here?
LocalDateTime.parse("2021-04-26T16:14:44.538+0000", DateTimeFormatter.ISO_ZONED_DATE_TIME);
doesn't work, even though all of the following work:
LocalDateTime.parse("2021-04-26T16:14:44.538+00:00", DateTimeFormatter.ISO_ZONED_DATE_TIME);
LocalDateTime.parse("2021-04-26T16:14:44.538+00", DateTimeFormatter.ISO_ZONED_DATE_TIME);
LocalDateTime.parse("2021-04-26T16:14:44.538Z", DateTimeFormatter.ISO_ZONED_DATE_TIME);
The same is true for ISO_OFFSET_DATE_TIME
. All of the above should imho. be valid ISO 8601 zone offsets.
Describe the bug
Yasson fails on offsets formatted as
+hhmm
and+hh
, even though they are considered valid ISO 8601 zone offsets (see https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators)To Reproduce
Expected behavior
Above works.
System information:
Additional context
The above examples works fine using
LocalDateTime.parse(isoDate, DateTimeFormatter.ISO_OFFSET_DATE_TIME)
.I will push a small test project to reproduce the issue shortly. Will link it here as soon as it is ready.
EDIT: Minimal project to reproduce can be found https://github.com/j-be/yasson-487