-
Enhancement
-
Resolution: Fixed
-
P4
-
9
-
b97
The Duration class has no methods to obtain the broken down parts of the duration. This has frustrated users, thus it seems wise to add methods to do this:
- toNanosPart()
- toMillisPart()
- toSecondsPart()
- toMinutesPart()
- toHoursPart()
- toDaysPart()
These would return the breakdown of the duration that is impossible to
access without user-written maths at present.
Given a duration of 49H30M20.123S
- toNanosPart() = 123000000
- toMillisPart() = 123
- toSecondsPart() = 20
- toMinutesPart() = 30
- toHoursPart() = 1
- toDaysPart() = 2
In addition, users have found the lack of a `toSeconds()` method confusing. The method exists, but is named `getSeconds()`, whereas all the similar methods are named `toXxx`. Adding a convenience method here would make the API more usable. Note that this will require renaming an existing private method.
- toNanosPart()
- toMillisPart()
- toSecondsPart()
- toMinutesPart()
- toHoursPart()
- toDaysPart()
These would return the breakdown of the duration that is impossible to
access without user-written maths at present.
Given a duration of 49H30M20.123S
- toNanosPart() = 123000000
- toMillisPart() = 123
- toSecondsPart() = 20
- toMinutesPart() = 30
- toHoursPart() = 1
- toDaysPart() = 2
In addition, users have found the lack of a `toSeconds()` method confusing. The method exists, but is named `getSeconds()`, whereas all the similar methods are named `toXxx`. Adding a convenience method here would make the API more usable. Note that this will require renaming an existing private method.
- relates to
-
JDK-8146489 @since tag missed
-
- Closed
-
-
JDK-8266901 Clarify the method description of Duration.toDaysPart()
-
- Closed
-