Skip to content

Add utility to parse Duration from a String #22474

@mp911de

Description

@mp911de
Member

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.

Activity

self-assigned this
on Feb 28, 2019
added
in: coreIssues in core modules (aop, beans, core, context, expression)
on Mar 5, 2019
ilyavy

ilyavy commented on Jan 21, 2020

@ilyavy

Relates to #22013

rstoyanchev

rstoyanchev commented on Aug 2, 2022

@rstoyanchev
Contributor

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.

added this to the 6.0.0-M6 milestone on Aug 2, 2022
modified the milestones: 6.0.0-M6, 6.0.0-RC1 on Sep 7, 2022
modified the milestones: 6.0.0-RC1, 6.1.x on Sep 15, 2022
self-assigned this
on Apr 24, 2023
simonbasle

simonbasle commented on May 16, 2023

@simonbasle
Contributor

linked to #22013 and superseded by gh-30396

removed this from the 6.1.x milestone on May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: supersededAn issue that has been superseded by anothertype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @bclozel@sbrannen@rstoyanchev@snicoll@mp911de

      Issue actions

        Add utility to parse Duration from a String · Issue #22474 · spring-projects/spring-framework