Provide a Converter<TimeUnit, ChronoUnit>
See original GitHub issuecurrently there’s no official way (in JDK 8) for converting between
java.util.concurrent.TimeUnit
andChronoUnit
(there will be in JDK 9, though).
So we should consider providing one. Maybe it’s time to start selectively open sourcing our com.google.common.time
package?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:11 (8 by maintainers)
Top Results From Across the Web
Converting TimeUnit to ChronoUnit? - java - Stack Overflow
Java 9. In Java 9 the TimeUnit API got extended and allows to convert between TimeUnit and ChronoUnit : TimeUnit.toChronoUnit() // returns a...
Read more >ChronoUnit (Java Platform SE 8 ) - Oracle Help Center
This set of units provide unit-based access to manipulate a date, time or date-time. The standard set of units can be extended by...
Read more >What is TimeUnit.toChronoUnit() in Java? - Educative.io
A ChronoUnit is an enum that represents a standard set of date periods units. This set of units provides unit-based access to manipulate...
Read more >Java Data Type How to - Convert java.util.concurrent.TimeUnit ...
Java Data Type How to - Convert java.util.concurrent.TimeUnit to java.time.temporal.ChronoUnit and back.
Read more >Convert time unit to duration in Java - Codeleak.pl
TimeUnit represents time durations in Java at a given unit of granularity and provides utility methods to convert across units.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We just made the transition to Java 8 internally last week, and we plan on releasing a Guava 21 (with Java8 support) sometime next quarter.
The reason we’ve been on the fence about adding this is that it already exists in
threeten-extra
as:Temporals.chronoUnit(TimeUnit)
Temporals.timeUnit(ChronoUnit)
And we’re hesitant to add competing solutions when a reasonable solution already exists.