spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Add utility to parse Duration from a String

Open mp911de opened this issue 6 years ago • 2 comments

It would make sense to have a common utility to parse java.time.Duration from a CharSequence.

Examples:

  • 10ms -> 10 milliseconds
  • 10s -> 10 seconds
  • 10m -> 10 minutes
  • 10h -> 10 hours

ChronoUnits to support:

  • Nanos
  • Micros
  • Millis
  • Seconds
  • Minutes
  • Hours
  • Days

Spring Boot provides this functionality and we'd like to reuse it in Spring Data.

mp911de avatar Feb 26 '19 10:02 mp911de

Relates to #22013

ilyavy avatar Jan 21 '20 11:01 ilyavy

Team Decision: We can do this in fallback mode, trying the built-in Duration formatting, and then falling back on alternative formats, in effect extending the built-in one. We should ensure the spec of what Boot supports already, works in the new arrangement.

rstoyanchev avatar Aug 02 '22 08:08 rstoyanchev

linked to #22013 and superseded by gh-30396

simonbasle avatar May 16 '23 09:05 simonbasle