Question regarding DateTime precision validation
Hi again,
Question: Why does a date with nanosecond precision fail in the validator?
Details: Recently i encountered a validation issue for my OffsetDateTimes when validating. I am using LocalTime.MAX in some cases which includes nanoseconds precision.
If those dates keep having nano precision my validation always fails, i had to use different workarounds e.g. using a dateFormatter feature for the objectmapper ("yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ).
As i read it nano precision is valid for ISO-8601 and RFC3339 is "a profile of ISO-8601".
I am unsure if nano precision would be valid and the validator does not consider all valid formats or if nano precision is NOT a valid RFC3339 format.
Thx in advance
Comments (3)
-
-
reporter Ok it is nice to know that i wasn't confused for no reason :D
Thanks very much for the response!
-
- changed status to resolved
Available in v1.0.19
- Log in to comment
Yep, I caught this one as well.
As of 1.0.18, the validation for date-time format is done using java.time.format.DateTimeFormater.ISO_DATE_TIME which is not exactly ISO-8601 (https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#ISO_DATE_TIME), and clearly missing out the time-fraction that is allowed in RFC3339. Unfortunately, according to Swagger specs, valid date-time format should follow RFC3339.
The good news is we can browse what has been done to solve this: https://github.com/java-json-tools/json-schema-validator/issues/143
But we need to state how many digits after the "." we support (as RFC3339 allows unlimited digits, e.g 1*DIGIT). 12 would be enough to cover your case..
Tuan