java.lang.Object | |
↳ | org.joda.time.base.BaseSingleFieldPeriod |
Known Direct Subclasses |
BaseSingleFieldPeriod is an abstract implementation of ReadablePeriod that manages a single duration field, such as days or minutes.
This class should generally not be used directly by API users.
The ReadablePeriod
interface should be used when different
kinds of period objects are to be referenced.
BaseSingleFieldPeriod subclasses may be mutable and not thread-safe.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a new instance representing the specified period.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Compares this period to another object of the same class.
| |||||||||||
Compares this object with the specified object for equality based on the
value of each field.
| |||||||||||
Gets the value of a duration field represented by this period.
| |||||||||||
Gets the field type at the specified index.
| |||||||||||
Gets the single duration field type.
| |||||||||||
Gets the period type which matches the duration field type.
| |||||||||||
Gets the value at the specified index.
| |||||||||||
Gets a hash code for the period as defined by ReadablePeriod.
| |||||||||||
Checks whether the duration field specified is supported by this period.
| |||||||||||
Gets the number of fields that this period supports, which is one.
| |||||||||||
Get this object as a
MutablePeriod . | |||||||||||
Get this period as an immutable
Period object. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Calculates the number of whole units between the two specified datetimes.
| |||||||||||
Calculates the number of whole units between the two specified partial datetimes.
| |||||||||||
Gets the amount of this period.
| |||||||||||
Sets the amount of this period.
| |||||||||||
Creates a new instance representing the number of complete standard length units
in the specified period.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Comparable
| |||||||||||
From interface
org.joda.time.ReadablePeriod
|
Creates a new instance representing the specified period.
period | the period to represent |
---|
Compares this period to another object of the same class.
other | the other period, must not be null |
---|
NullPointerException | if the other period is null |
---|---|
ClassCastException | if the other period is of a different type |
Compares this object with the specified object for equality based on the
value of each field. All ReadablePeriod instances are accepted, but only
those with a matching PeriodType
can return true.
period | a readable period to check against |
---|
Gets the value of a duration field represented by this period.
If the field type specified does not match the type used by this class then zero is returned.
type | the field type to query, null returns zero |
---|
Gets the field type at the specified index.
The only index supported by this period is zero which returns the field type of this class.
index | the index to retrieve, which must be zero |
---|
IndexOutOfBoundsException | if the index is invalid |
---|
Gets the single duration field type.
Gets the period type which matches the duration field type.
Gets the value at the specified index.
The only index supported by this period is zero.
index | the index to retrieve, which must be zero |
---|
IndexOutOfBoundsException | if the index is invalid |
---|
Gets a hash code for the period as defined by ReadablePeriod.
Checks whether the duration field specified is supported by this period.
type | the type to check, may be null which returns false |
---|
Gets the number of fields that this period supports, which is one.
Get this object as a MutablePeriod
.
This will always return a new MutablePeriod
with the same fields.
The period will use PeriodType.standard()
.
Get this period as an immutable Period
object.
The period will use PeriodType.standard()
.
Period
representing the same number of days
Calculates the number of whole units between the two specified datetimes.
start | the start instant, validated to not be null |
---|---|
end | the end instant, validated to not be null |
field | the field type to use, must not be null |
IllegalArgumentException | if the instants are null or invalid |
---|
Calculates the number of whole units between the two specified partial datetimes.
The two partials must contain the same fields, for example you can specify
two LocalDate
objects.
start | the start partial date, validated to not be null |
---|---|
end | the end partial date, validated to not be null |
zeroInstance | the zero instance constant, must not be null |
IllegalArgumentException | if the partials are null or invalid |
---|
Gets the amount of this period.
Sets the amount of this period. To make a subclass immutable you must declare it final, or block this method.
value | the period value |
---|
Creates a new instance representing the number of complete standard length units in the specified period.
This factory method converts all fields from the period to hours using standardised durations for each field. Only those fields which have a precise duration in the ISO UTC chronology can be converted.
period | the period to get the number of hours from, must not be null |
---|---|
millisPerUnit | the number of milliseconds in one standard unit of this period |
IllegalArgumentException | if the period contains imprecise duration values |
---|