Support use of "pattern" (`ChronoUnit`) for `DurationSerializer` too
See original GitHub issue(see #184 for background)
So, we should support use of @JsonFormat(pattern = "HOURS")
(and “config override” equivalent) for writing too. As discussed on #184, there is gnarly challenge with backwards-compatibility – change should only affect explicit pattern-using case.
Another challenge is the possibility of fractional values: given Duration
may not be exactly divisible by desired unit: for example, we might have “90 seconds” as value, but configured to use “minutes”, resulting in 1.5
(ideally).
If it is possible to calculate this accurately (enough), I’d like to do that, but I am not sure it is.
If not, I suggest that only one specific case of fractions would be supported: that of “SECONDS” as explicit unit. It would be output as fractions as needed, based on underlying seconds/nanoseconds values.
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (12 by maintainers)
I think that constructor is probably called from
createContextual()
, and should not bepublic
.Hey guys, can I take this one too? Thanks in advance