-
Notifications
You must be signed in to change notification settings - Fork 82
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
DateTimeSerializer does not respect SerializationFeature WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS #54
Comments
This is a rather tricky one -- I agree in principle here, but the implications for backwards compatibility can be tricky. So it would be worth discussing on Jackson dev list. If consensus is that we should just go ahead, I'd be happy to change it or merge a patch that does this. |
Actually, the solution is not that simple (multiplication by 1000), firstly, because the multiplication is by 1000000 (oops :)) and secondly this could cause the value to be too big for a |
@cowtowncoder Is there a suggested way to go here? Happy to create a PR for this, but for that I'd like to know what your concerns are? |
I have just noticed that the javadocs specifically say that only those modules should respect these serialization settings if the data type they serialize has nano resolution. This however leaves no room for making the joda module work with jsr310 in case jsr310 serializes in nanos. Either the API contract could be changed which would break backwards compatibility or a new switch could be introduced for the modules which do not support nano precision (would be awkward). I was also thinking if it was possible - or desirable - to introduce module-level serialization/deserialization features which would only specify api contracts on the behaviour of the module itself. That would allow a less generic configuration of modules which probably would be easier to understand in cases which are specific to modules. |
FWIW, I think it is completely reasonable to have module-level configuration. However, there is one practical challenge: whereas global |
I am not sure how to proceed with this one; it probably has to be part of bigger concentrated overhaul for 3.x; maybe to allow 4 alternative timestamp base units: |
Serialization feature
WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS
is enabled by default in Jackson. Joda does not have nano precision. The solution to this should be an optional multiplication by 1000 when necessary when serializing (and deserializing) as well.The text was updated successfully, but these errors were encountered: