-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Large ISO-8601 Dates are formatted/serialized incorrectly #2167
Comments
Good catch. I agree, one or the other should be supported; ideally probably support for years beyond 9999. |
If you want to support years The ISO spec requires a 4 numeral year, so, if year Beyond that, the spec optionally specifies that years can have 5 or more numerals, and that years before 1CE have a negative sign, starting at 0. So, The spec also says that if there is an agreement between the parties that exchange the information, then the application can use the signed big year format. So, there should be a toggle to enable that, and by default make it limited to |
I think I'll leave support for BCE for another issue if anyone has time and interest, and this will be focused on improving handling of future dates. |
Or. Hmmh. Reading this: https://www.tondering.dk/claus/cal/iso8601.php is interesting, mentioning that positive prefix must be used 5-or-more digits (and Of course, being able to deserialize any of that is yet another issue. |
The problem
Years > 9999 are not rendered as 5 numbers or more, but with a non numerical characters for the thousands digit..
The testcase
Expected
a) All dates are formatted correctly, meaning, years bigger than 9999.
b) or some sort of exception telling the data is not supported.
The location
'0' + something
https://github.com/FasterXML/jackson-databind/blob/master/src/main/java/com/fasterxml/jackson/databind/util/StdDateFormat.java#L442
Suggestion
a) Adding '0' with an integer is not a safe operation. But if you are doing it, you need an upper bound check, e.g.:
b) Or if you do not want to support such high years, then throw some sort of exception. E.g.:
The text was updated successfully, but these errors were encountered: