Skip to content

timeAndDate() should use java.time.temporal.TemporalUnit rather than java.util.concurrent.TimeUnit #1911

Description

@sco0ter

Is your feature request related to a problem? Please describe.

I want to use: timeAndDate().past(10, TimeUnit.of(ChronoUnit.YEARS)). However it's not possible to convert this:

java.lang.IllegalArgumentException: No TimeUnit equivalent for Years

The issue is: java.util.concurrent.TimeUnit is inappropriate for date operations, because the largest unit is "days".

Describe the solution you'd like

I propose to not use java.util.concurrent.TimeUnit here at all. Instead use java.time.temporal.TemporalUnit, so that we can use the API like this:

timeAndDate().past(10, ChronoUnit.YEARS)

Describe alternatives you've considered

timeAndDate().past(java.time.Duration duration) might also be a good idea.

Additional context

This proposal also affects other APIs, at least timeAndDate().future()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions