java.lang.Object | |
↳ | org.joda.time.base.AbstractPeriod |
Known Direct Subclasses |
Known Indirect Subclasses |
AbstractPeriod provides the common behaviour for period classes.
This class should generally not be used directly by API users. The
ReadablePeriod
interface should be used when different
kinds of periods are to be referenced.
AbstractPeriod subclasses may be mutable and not thread-safe.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Compares this object with the specified object for equality based
on the value of each field.
| |||||||||||
Gets the value of one of the fields.
| |||||||||||
Gets an array of the field types that this period supports.
| |||||||||||
Gets an array of the value of each of the fields that this period supports.
| |||||||||||
Gets a hash code for the period as defined by ReadablePeriod.
| |||||||||||
Gets the index of the field in this period.
| |||||||||||
Checks whether the field specified is supported by this period.
| |||||||||||
Get this object as a
MutablePeriod . | |||||||||||
Get this period as an immutable
Period object. | |||||||||||
Uses the specified formatter to convert this period to a String.
| |||||||||||
Gets the value as a String in the ISO8601 duration format.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.joda.time.ReadablePeriod
|
Constructor.
Compares this object with the specified object for equality based on the value of each field. All ReadablePeriod instances are accepted.
Note that a period of 1 day is not equal to a period of 24 hours, nor is 1 hour equal to 60 minutes. Only periods with the same amount in each field are equal.
This is because periods represent an abstracted definition of a time period (eg. a day may not actually be 24 hours, it might be 23 or 25 at daylight savings boundary).
To compare the actual duration of two periods, convert both to
Duration
s, an operation that emphasises
that the result may differ according to the date you choose.
period | a readable period to check against |
---|
Gets the value of one of the fields.
If the field type specified is not supported by the period then zero is returned.
type | the field type to query, null returns zero |
---|
Gets an array of the field types that this period supports.
The fields are returned largest to smallest, for example Hours, Minutes, Seconds.
Gets an array of the value of each of the fields that this period supports.
The fields are returned largest to smallest, for example Hours, Minutes, Seconds.
Each value corresponds to the same array index as getFields()
Gets a hash code for the period as defined by ReadablePeriod.
Gets the index of the field in this period.
type | the type to check, may be null which returns -1 |
---|
Checks whether the field specified is supported by this period.
type | the type to check, may be null which returns false |
---|
Get this object as a MutablePeriod
.
This will always return a new MutablePeriod
with the same fields.
Get this period as an immutable Period
object.
Uses the specified formatter to convert this period to a String.
formatter | the formatter to use, null means use toString() . |
---|
Gets the value as a String in the ISO8601 duration format.
For example, "P6H3M7S" represents 6 hours, 3 minutes, 7 seconds.
For more control over the output, see
PeriodFormatterBuilder
.