Java 8 introduced ChronoUnit which is largely equivalent to TimeUnit introduced in Java 5.
Is there an existing function for converting a TimeUnit to ChronoUnit? (Yes, I know how to write my own)
In Java 9 the TimeUnit
API got extended and allows to convert between TimeUnit
and ChronoUnit
:
TimeUnit.toChronoUnit() // returns a ChronoUnit
TimeUnit.of(ChronoUnit chronoUnit) // returns a TimeUnit
see: JDK-8141452