question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, Oct 22, 2020

I think that constructor is probably called from createContextual(), and should not be public.

1reaction
obarcelonapcommented, Oct 20, 2020

Hey guys, can I take this one too? Thanks in advance

Read more comments on GitHub >

github_iconTop Results From Across the Web

ChronoUnit (Java Platform SE 8 ) - Oracle Help Center
Enum ChronoUnit. A standard set of date periods units. This set of units provide unit-based access to manipulate a date, time or date-time....
Read more >
java.time.Duration.minusMinutes java code examples - Tabnine
MAX_VALUE) { throw new IllegalArgumentException( String.format("duration %s too large to be represented unambiguously as postgres interval", d)); } d = d.
Read more >
Jackson问题分析_Refining&的博客
LocalDateTime` not supported by default: add Module ... ChronoUnit #189: Support use of "pattern" (ChronoUnit) for DurationSerializer too.
Read more >
Why Instant does not support operations with ChronoUnit ...
I'm taking a stab at it in what looks to me like something very logical. Here is the code for the method plus(long,...
Read more >
Set of support modules for Java 8 datatypes (Optionals, date ...
When used with Jackson 2.x, Java 8 support is provided via 3 ... Support use of "pattern" (`ChronoUnit`) for `DurationSerializer` too.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found