-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_TIMESTAMPS
to allow parsing quoted numbers when using a custom DateTimeFormatter
#263
Comments
On adding feature: PRs welcome. |
Cheers! I'll try and rustle up something. |
There is an apparent inconsistency in the way Jackson de-serializes numbers that are shaped as a string into an instant. * When not providing a custom date format, quoted numbers are treated as epoch milis/nanos * When not providing a custom date, quoted numbers are assumed to be handled by the pattern. There is however no way to construct a pattern that handles both ISO dates and epoch milis/nanos. This feature toggle allow numeric strings to be read as numeric timestamps. Fixes FasterXML#263
Hmmh. But what is the need to use "quoted numbers" instead of plain numbers? |
Unfortunately the data I'm reading is using timestamps formatted as quoted numbers. The systems producing this data are rather old and peculiar. And I would agree that in principle they need not be this way. But this is the reality I'm working with. Nevertheless, without a formatter (i.e. Unfortunately I can not access the issue that prompted the original addition of the "read qouted numbers as timestamps" feature ( So I am not looking to enable a novel use for quoted numbers, rather I'm looking to make an already supported use-case consistent with other features of the library. |
Ok. That makes sense. So, I am not against supporting such use cases; my main concern is with API. Unfortunately whereas there is now extensive configurability for "alternative Shapes" (accept But I am trying to limit use of Given this, I think I would actually suggest adding configurability in If this can be done, I'd be happy to get it merged. I'll add similar note to |
Cheers. I'll have a look at how to accomplish this. Might take a little while. |
There is an apparent inconsistency in the way Jackson de-serializes numbers that are shaped as a string into an instant. * When not providing a custom date format, quoted numbers are treated as epoch milis/nanos * When not providing a custom date, quoted numbers are assumed to be handled by the pattern. There is however no way to construct a pattern that handles both ISO dates and epoch milis/nanos. This feature toggle allow numeric strings to be read as numeric timestamps. Fixes FasterXML#263
JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_TIMESTAMPS
to allow parsing quoted numbers when using a custom DateTimeFormatter
I have a scenario where I would like to de-serialize epoch milis, and serialize with a
@JsonFormat
annotation. In essence:This will fail on the last assertion with:
There is an apparent inconsistency in the way Jackson de-serializes numbers that are shaped as a string into an instant.
jackson-modules-java8/datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java
Lines 267 to 277 in 8693cf9
There is however no way to construct a pattern that handles both ISO dates and epoch milis/nanos. Would it be possible to add a feature toggle here?
Details:
The text was updated successfully, but these errors were encountered: