How do I convert a Time4J Duration<ClockUnit>
to a number of minutes? I’m fine with truncating any seconds, I just want the whole minutes. A couple of simple examples probably explain the best:
- For
Duration.of(1, ClockUnit.HOURS)
I want 60. - For
Duration.of(34, ClockUnit.SECONDS)
I want 0.
There isn’t any toMinutes
method (like there is in java.time.Duration
). I played around with a Normalizer
, the getTotalLength
method and a stream operation and got a 6 lines solution to work, but surely there is a simpler way?
The solutions for hours and seconds could also be interesting, but I expect them to be more or less trivial modifications of the solution for minutes.