You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So. While older JDK versions (up to JDK 7) always wrote timezone offset, if any, without colon, like:
+0000
ISO-8601 specification expects minute/hour part to be separated by a colon like
+00:00
While #1744 added an option to enable this behavior, it has not been default for Jackson.
Let's change it in 2.11.
A note on implementation: a new SerializationFeature setting was briefly considered, but wiring of such setting to be used proved difficult. Users can still use method in StdDateFormat
That's not competely true. ISO 8601 provides two formats, basic and extended. So both outputs are valid as long as the rest of the timestamp adheres to the same format. Since Jackson uses extended format exclusively, the current behavior is wrong.
This statement is problematic, even wrong. X cannot be used for RFC and ISO. The subtile difference is that is will always serialize Zulu with Z, never +0000 or 00:00.
I'd say that the Javadoc of WRITE_DATES_AS_TIMESTAMPS is acceptable. StdDateFormat needs imrovements for 3.0. It is a bit of a mess with respect to ISO 8601.
@michael-o I want to make sure I understand this part:
X cannot be used for RFC and ISO. The subtile difference is that is will always serialize Zulu with Z, never +0000 or 00:00.
As far as I can read JDK javadocs, X does produce Z for zero timezone offset; one that is legal (as well as alternate +00[:00]) for ISO-8601 as well. So I assume those are not problem parts.
So I assume you refer to the current (2.11) implementation of StdDateFormat, which does (for now) produce only numeric offset. This is easy to change, as comments already indicate (although claiming older specs being problematic, I'll change comment) that behavior was chosen for backwards compatibility.
Since changing that part (+00:00 -> Z) is yet another theoretically tiny, but in practice highly visible -- most likely causing tons of bogus test failures, but also breaking some amount of fragile code -- it seems best to only change colon inclusion for 2.11, and do +00:00 -> Z for 3.0 now. We can consider switch in 2.12 as well, depending on how 2.11 release goes.
Activity
Fix #2643: add colon in timezone offset for better ISO-8601 compliance
SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
#1624michael-o commentedon Mar 5, 2020
That's not competely true. ISO 8601 provides two formats, basic and extended. So both outputs are valid as long as the rest of the timestamp adheres to the same format. Since Jackson uses extended format exclusively, the current behavior is wrong.
cowtowncoder commentedon Mar 5, 2020
@michael-o Ok. I think this was mentioned in an earlier discussion, but was not sure how to describe it. So, two questions:
Also related, for overall change plans wrt Date/Time type handling:
https://github.com/FasterXML/jackson-future-ideas/wiki/JSTEP-5
where it'd be good to first group distinct ideas of improvements needed, in detail.
michael-o commentedon Mar 5, 2020
Z
has ben designed for RFC dates and not for ISO dates like telescopingX
.cowtowncoder commentedon Mar 5, 2020
@michael-o Meant specifically wrt Javadoc for
SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
primarily, and perhaps this issue title secondarily.One more fix wrt #2643
michael-o commentedon Mar 6, 2020
New title: Change default textual serialization of
java.util.Date
/Calendar
for the timezone offset to comply with ISO 8601 extended format.I will review the Javadoc of
SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
.michael-o commentedon Mar 6, 2020
See this part:
https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/util/StdDateFormat.java#L18-L22
This statement is problematic, even wrong.
X
cannot be used for RFC and ISO. The subtile difference is that is will always serialize Zulu withZ
, never+0000
or00:00
.I'd say that the Javadoc of
WRITE_DATES_AS_TIMESTAMPS
is acceptable.StdDateFormat
needs imrovements for 3.0. It is a bit of a mess with respect to ISO 8601.minor comment add wrt #2643
cowtowncoder commentedon Mar 6, 2020
@michael-o I want to make sure I understand this part:
As far as I can read JDK javadocs,
X
does produceZ
for zero timezone offset; one that is legal (as well as alternate +00[:00]) for ISO-8601 as well. So I assume those are not problem parts.So I assume you refer to the current (2.11) implementation of
StdDateFormat
, which does (for now) produce only numeric offset. This is easy to change, as comments already indicate (although claiming older specs being problematic, I'll change comment) that behavior was chosen for backwards compatibility.Since changing that part (+00:00 -> Z) is yet another theoretically tiny, but in practice highly visible -- most likely causing tons of bogus test failures, but also breaking some amount of fragile code -- it seems best to only change colon inclusion for 2.11, and do +00:00 -> Z for 3.0 now. We can consider switch in 2.12 as well, depending on how 2.11 release goes.
Does above make sense?
13 remaining items
Update tests to reflect changes in FasterXML/jackson-databind#2643
chore: organize dependency versions and update vulnerable jackson-dat…
chore: organize dependency versions and update vulnerable jackson-dat…
chore(deps): bump swagger-codegen to 3.0.27 (#11743)
chore: organize dependency versions and update vulnerable jackson-dat…
chore(deps): bump swagger-codegen to 3.0.27 (#11743)
chore: organize dependency versions and update vulnerable jackson-dat…
chore(deps): bump swagger-codegen to 3.0.27 (#11743)
chore: organize dependency versions and update vulnerable jackson-dat…
chore(deps): bump swagger-codegen to 3.0.27 (#11743)
chore: organize dependency versions and update vulnerable jackson-dat…
chore(deps): bump swagger-codegen to 3.0.27 (#11743)