-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ISO8601DateFormat is deprecated but replacement is unclear. #1786
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
Comments
Correct: You are correct in that you should just remove that I'll see if I can find more information on last Jackson version that actually used |
Ok. So, the class has been include since 2.0 at least (Jackson moved to github at that version), but was never actually used by rest of databind code. I do not recall its history: I do not usually include utility classes that are not bound or accessed by API. It is possible this might have been due to refactoring since 1.9. If there is any documentation that suggest use of this class I would want to update it. |
I can't tell you where I originally found a reference to that class but I'm 100% sure it dates back to 2010 or 2011. From there it was copy-pasted to every new ObjectMapper configuration because "Of course we want ISO-8601". ¯\(ツ)/¯ No problem at all, I just wanted to check back before removing it all over the code base. Thanks for the fast reply! |
@huxi lol. Yes, apologies for breaking change here -- I can totally see why it would make sense from user perspective, esp. considering that documentation has always been bit sparse. So: yes, this mysterious class is gone and should not be needed. |
For posterity, here's an example of serializing to iso8601 without the ISO8601DateFormat class from the jackson tests themselves: jackson-databind/src/test/java/com/fasterxml/jackson/databind/ser/jdk/DateSerializationTest.java Line 118 in b1aa8e3
|
Looks like default I found this while integrating with a 3rd party API which uses Swagger spec.
According to the RFC the timezone information must follow this BNF:
Notice the Not sure if that's an issue in RFC or Swagger, but I cannot really use the default |
Migrating from Jackson 2.8.11 to 2.9.8, and am finding that for a given date, Note that the format returned by ISO8601DateFormat is listed as the default in the JavaDocs. |
@rhwood
and defining (for example) properly configured mapper.configOverride(Date.class)
.setFormat(JsonFormat.Value.forPattern("yyyy.dd.MM")); in which case a
|
@dmitrygusev There is addition of |
Ok, so Javadoc might be correct I think, although it may be misleading: it states that "Format String" looks like
|
I also found that StdDateFormat cannot be used as is in place of ISO8601DateFormat because Go cannot parse StdDateFormat output. To be exact, Go doesn't support parsing timezone offset without colon. Using It is because in section 5.6. Internet Date/Time Format of RFC 3339 colon is not optional:
So, while both variants (with and without colon) are valid ISO-8601, using colon improves interoperability with other software that doesn't implement full ISO-8601 spec but only a subset recommended by RFC 3339 for internet communication. |
com.fasterxml.jackson.databind.util.ISO8601DateFormat
is deprecated since 2.9 but I couldn't find any information about how to replace its current usage while upgrading.So far, I checked the following locations:
But no luck...
I suspect that I could probably just delete
objectMapper.setDateFormat(new ISO8601DateFormat());
and be fine but I wanted to double-check.So this is a bug report against the documentation, not the code. If it can be safely removed and dates are still serialized as ISO-8601 strings then this should be mentioned somewhere.
The text was updated successfully, but these errors were encountered: