-
Notifications
You must be signed in to change notification settings - Fork 122
OffsetDateTime
deserialization does not handle nano seconds correctly
#71
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
which will handle the value as epoch seconds, rather than nano second.
|
the timestamp value is treated at the integer part, not the fraction part. |
Ok, now I see the point, and agree, this does seem incorrect, but maybe more of a documentation issue at the very least, or deprecating the READ_DATE_TIMESTAMPS_AS_NANOSECONDS variable name, and changing it to READ_DATE_TIMESTAMPS_AS_EPOCH_SECONDS? |
See similar issue #109 |
TBH, as an non English speaker, I totally cannot understand what the last sentence starting by "The more ambiguous integer types..." is speaking... Then I tried to read the code to understand it, but in the code, the nano part (the fractional number) is always 0, I was totally confused at that time. Even if we change the name to READ_DATE_TIMESTAMPS_AS_SECONDS, the source is still not making sense: why do we need to handle fraction here? I think there are 2 issues here:
I would suggest to deprecate this feature, or change it to a simple form that, just treat the string as an long integer of nanosecond. And further, as some languages sdks use second as default precision, thus it would be convinient have a configuration of read data as second. Last, since default java time stamp is millisecond, I would suggest use millisecond as default configuration. |
I can not comment on all the details as I did not author this module, but here are some of my thoughts that are relevant. First, on ambiguousness: I think what sentence tries to say is this:
Given (2), it is not very sensible to use milliseconds as base unit with Java 8 date/time types as that would make it impossible to use full accuracy. I am not sure use of seconds for that case would make sense either. At the same time, I do see it problematic that other systems / standards use millisecond ("old" Java) or second (Unix) as base unit for timestamps, since their integer values can then easily be misinterpreted. |
Hi Guys, Finally got something here - You can actually specify your precision it seems
I find myself happy with the implementation, also found this out because JDK 12 no longer accepts null as a pattern and forces you to specify the format accurately, can't have any |
@GedMarc I know you added a note on Afterburner issue, but could you also create an issue here, along with "easy" label (I think)? We have some new contributors who might be able to resolve the null formatter problem faster than I can -- I think there is a default to use, or alternatively call different method. There may be some logic in base class that assumes |
(moved from https://github.com/FasterXML/jackson-datatype-jsr310/issues/96 by @xzer)
when InstantDeserializer get a long value for OffsetDateTime, it will entering the following method:
Notice that, with the default configuration, READ_DATE_TIMESTAMPS_AS_NANOSECONDS is true, it will create a FromDecimalArguments with the passed timestamp value, and which will be passed to the following source:
to be precision, the following row:
which will handle the value as epoch seconds, rather than nano second.
Is there anything that I misunderstand? Or it is actually a bug?
The text was updated successfully, but these errors were encountered: