Skip to content

Support use of "pattern" (ChronoUnit) for DurationSerializer too #189

@cowtowncoder

Description

@cowtowncoder

(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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    hacktoberfestIssue related to Hactoberfest2020 activities, eligible for additional rewards

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions