Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
org.joda.time.base.AbstractDuration
ReadableDuration
interface should be used when different
kinds of durations are to be referenced.
AbstractDuration subclasses may be mutable and not thread-safe.
Constructor Summary | |
|
Method Summary | |
int |
|
boolean |
|
int |
|
boolean |
|
boolean |
|
boolean |
|
Duration |
|
Period |
|
String |
|
public int compareTo(Object obj)
Compares this duration with the specified duration based on length.
- Specified by:
- compareTo in interface ReadableDuration
- Parameters:
obj
- a duration to check against
- Returns:
- negative value if this is less, 0 if equal, or positive value if greater
public boolean equals(Object duration)
Compares this object with the specified object for equality based on the millisecond length. All ReadableDuration instances are accepted.
- Specified by:
- equals in interface ReadableDuration
- Parameters:
duration
- a readable duration to check against
- Returns:
- true if the length of the duration is equal
public int hashCode()
Gets a hash code for the duration that is compatible with the equals method.
- Specified by:
- hashCode in interface ReadableDuration
- Returns:
- a hash code
public boolean isEqual(ReadableDuration duration)
Is the length of this duration equal to the duration passed in.
- Specified by:
- isEqual in interface ReadableDuration
- Parameters:
duration
- another duration to compare to, null means zero milliseconds
- Returns:
- true if this duration is equal to than the duration passed in
public boolean isLongerThan(ReadableDuration duration)
Is the length of this duration longer than the duration passed in.
- Specified by:
- isLongerThan in interface ReadableDuration
- Parameters:
duration
- another duration to compare to, null means zero milliseconds
- Returns:
- true if this duration is equal to than the duration passed in
public boolean isShorterThan(ReadableDuration duration)
Is the length of this duration shorter than the duration passed in.
- Specified by:
- isShorterThan in interface ReadableDuration
- Parameters:
duration
- another duration to compare to, null means zero milliseconds
- Returns:
- true if this duration is equal to than the duration passed in
public Duration toDuration()
Get this duration as an immutableDuration
object.
- Specified by:
- toDuration in interface ReadableDuration
- Returns:
- a Duration created using the millisecond duration from this instance
public Period toPeriod()
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, seePeriod.Period(ReadableInstant,ReadableDuration)
.
- Specified by:
- toPeriod in interface ReadableDuration
- Returns:
- a Period created using the millisecond duration from this instance
public String toString()
Gets the value as a String in the ISO8601 duration format including only seconds and milliseconds. For example, "PT72.345S" represents 1 minute, 12 seconds and 345 milliseconds. For more control over the output, seePeriodFormatterBuilder
.
- Specified by:
- toString in interface ReadableDuration
- Returns:
- the value as an ISO8601 string