org.joda.time.ReadableDuration |
Known Indirect Subclasses |
Defines an exact duration of time in milliseconds.
The implementation of this interface may be mutable or immutable. This interface only gives access to retrieve data, never to change it.
Methods that are passed a duration as a parameter will treat null
as a zero length duration.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Compares this duration with the specified duration based on length.
| |||||||||||
Compares this object with the specified object for equality based
on the millisecond length.
| |||||||||||
Gets the total length of this duration in milliseconds.
| |||||||||||
Gets a hash code for the duration that is compatable with the
equals method.
| |||||||||||
Is the length of this duration equal to the duration passed in.
| |||||||||||
Is the length of this duration longer than the duration passed in.
| |||||||||||
Is the length of this duration shorter than the duration passed in.
| |||||||||||
Get this duration as an immutable
Duration object. | |||||||||||
Converts this duration to a Period instance using the standard period type
and the ISO chronology.
| |||||||||||
Gets the value as a String in the ISO8601 duration format using hours,
minutes and seconds (including fractional milliseconds).
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
java.lang.Comparable
|
Compares this duration with the specified duration based on length.
obj | a duration to check against |
---|
NullPointerException | if the object is null |
---|---|
ClassCastException | if the given object is not supported |
Compares this object with the specified object for equality based on the millisecond length. All ReadableDuration instances are accepted.
readableDuration | a readable duration to check against |
---|
Gets the total length of this duration in milliseconds.
Gets a hash code for the duration that is compatable with the equals method. The following formula must be used:
long len = getMillis(); return (int) (len ^ (len >>> 32));
Is the length of this duration equal to the duration passed in.
duration | another duration to compare to, null means zero milliseconds |
---|
Is the length of this duration longer than the duration passed in.
duration | another duration to compare to, null means zero milliseconds |
---|
Is the length of this duration shorter than the duration passed in.
duration | another duration to compare to, null means zero milliseconds |
---|
Get this duration as an immutable Duration
object.
This will either typecast this instance, or create a new Duration
.
Converts this duration to a Period instance using the standard period type and the ISO chronology.
Only precise fields in the period type will be used. Thus, only the hour, minute, second and millisecond fields on the period will be used. The year, month, week and day fields will not be populated.
If the duration is small, less than one day, then this method will perform as you might expect and split the fields evenly. If the duration is larger than one day then all the remaining duration will be stored in the largest available field, hours in this case.
For example, a duration effectively equal to (365 + 60 + 5) days will be converted to ((365 + 60 + 5) * 24) hours by this constructor.
For more control over the conversion process, you must pair the duration with
an instant, see Period(ReadableInstant, ReadableDuration)
.
Gets the value as a String in the ISO8601 duration format using hours, minutes and seconds (including fractional milliseconds).
For example, "PT6H3M7S" represents 6 hours, 3 minutes, 7 seconds.