java.lang.Object | ||
↳ | org.joda.time.base.AbstractPeriod | |
↳ | org.joda.time.base.BasePeriod |
Known Direct Subclasses |
BasePeriod is an abstract implementation of ReadablePeriod that stores
data in a PeriodType
and an int[]
.
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.
BasePeriod subclasses may be mutable and not thread-safe.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a period from a set of field values.
| |||||||||||
Creates a period from the given interval endpoints.
| |||||||||||
Creates a period from the given interval endpoints.
| |||||||||||
Creates a period from the given duration and end point.
| |||||||||||
Creates a period from the given start point and duration.
| |||||||||||
Creates a period from the given duration and end point.
| |||||||||||
Creates a period from the given millisecond duration, which is only really
suitable for durations less than one day.
| |||||||||||
Creates a new period based on another using the
ConverterManager . | |||||||||||
Constructor used when we trust ourselves.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the field type at the specified index.
| |||||||||||
Gets the period type.
| |||||||||||
Gets the value at the specified index.
| |||||||||||
Gets the number of fields that this period supports.
| |||||||||||
Gets the total millisecond duration of this period relative to a start instant.
| |||||||||||
Gets the total millisecond duration of this period relative to an
end instant.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds the value of a field in this period.
| |||||||||||
Adds the value of a field in this period.
| |||||||||||
Adds the fields from another period.
| |||||||||||
Adds the fields from another period.
| |||||||||||
Validates a period type, converting nulls to a default value and
checking the type is suitable for this instance.
| |||||||||||
Merges the fields from another period.
| |||||||||||
Merges the fields from another period.
| |||||||||||
Sets the value of a field in this period.
| |||||||||||
Sets the value of a field in this period.
| |||||||||||
Sets all the fields of this period from another.
| |||||||||||
Sets the eight standard the fields in one go.
| |||||||||||
Sets the value of the field at the specifed index.
| |||||||||||
Sets the values of all fields.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.joda.time.base.AbstractPeriod
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.joda.time.ReadablePeriod
|
Creates a period from a set of field values.
years | amount of years in this period, which must be zero if unsupported |
---|---|
months | amount of months in this period, which must be zero if unsupported |
weeks | amount of weeks in this period, which must be zero if unsupported |
days | amount of days in this period, which must be zero if unsupported |
hours | amount of hours in this period, which must be zero if unsupported |
minutes | amount of minutes in this period, which must be zero if unsupported |
seconds | amount of seconds in this period, which must be zero if unsupported |
millis | amount of milliseconds in this period, which must be zero if unsupported |
type | which set of fields this period supports |
IllegalArgumentException | if period type is invalid |
---|---|
IllegalArgumentException | if an unsupported field's value is non-zero |
Creates a period from the given interval endpoints.
startInstant | interval start, in milliseconds |
---|---|
endInstant | interval end, in milliseconds |
type | which set of fields this period supports, null means standard |
chrono | the chronology to use, null means ISO default |
IllegalArgumentException | if period type is invalid |
---|
Creates a period from the given interval endpoints.
startInstant | interval start, null means now |
---|---|
endInstant | interval end, null means now |
type | which set of fields this period supports, null means standard |
IllegalArgumentException | if period type is invalid |
---|
Creates a period from the given duration and end point.
The two partials must contain the same fields, thus you can
specify two LocalDate
objects, or two LocalTime
objects, but not one of each.
As these are Partial objects, time zones have no effect on the result.
The two partials must also both be contiguous - see
isContiguous(ReadablePartial)
for a
definition. Both LocalDate
and LocalTime
are contiguous.
start | the start of the period, must not be null |
---|---|
end | the end of the period, must not be null |
type | which set of fields this period supports, null means standard |
IllegalArgumentException | if the partials are null or invalid |
---|
Creates a period from the given start point and duration.
startInstant | the interval start, null means now |
---|---|
duration | the duration of the interval, null means zero-length |
type | which set of fields this period supports, null means standard |
Creates a period from the given duration and end point.
duration | the duration of the interval, null means zero-length |
---|---|
endInstant | the interval end, null means now |
type | which set of fields this period supports, null means standard |
Creates a period from the given millisecond duration, which is only really suitable for durations less than one day.
Only fields that are precise will be used. Thus the largest precise field may have a large value.
duration | the duration, in milliseconds |
---|---|
type | which set of fields this period supports, null means standard |
chrono | the chronology to use, null means ISO default |
IllegalArgumentException | if period type is invalid |
---|
Creates a new period based on another using the ConverterManager
.
period | the period to convert |
---|---|
type | which set of fields this period supports, null means use type from object |
chrono | the chronology to use, null means ISO default |
IllegalArgumentException | if period is invalid |
---|---|
IllegalArgumentException | if an unsupported field's value is non-zero |
Constructor used when we trust ourselves. Do not expose publically.
values | the values to use, not null, not cloned |
---|---|
type | which set of fields this period supports, not null |
Gets the field type at the specified index.
index | the index to retrieve |
---|
IndexOutOfBoundsException | if the index is invalid |
---|
Gets the value at the specified index.
index | the index to retrieve |
---|
IndexOutOfBoundsException | if the index is invalid |
---|
Gets the number of fields that this period supports.
Gets the total millisecond duration of this period relative to a start instant.
This method adds the period to the specified instant in order to calculate the duration.
An instant must be supplied as the duration of a period varies. For example, a period of 1 month could vary between the equivalent of 28 and 31 days in milliseconds due to different length months. Similarly, a day can vary at Daylight Savings cutover, typically between 23 and 25 hours.
startInstant | the instant to add the period to, thus obtaining the duration |
---|
ArithmeticException | if the millis exceeds the capacity of the duration |
---|
Gets the total millisecond duration of this period relative to an end instant.
This method subtracts the period from the specified instant in order to calculate the duration.
An instant must be supplied as the duration of a period varies. For example, a period of 1 month could vary between the equivalent of 28 and 31 days in milliseconds due to different length months. Similarly, a day can vary at Daylight Savings cutover, typically between 23 and 25 hours.
endInstant | the instant to subtract the period from, thus obtaining the duration |
---|
ArithmeticException | if the millis exceeds the capacity of the duration |
---|
Adds the value of a field in this period.
field | the field to set |
---|---|
value | the value to set |
IllegalArgumentException | if field is is null or not supported. |
---|
Adds the value of a field in this period.
values | the array of values to update |
---|---|
field | the field to set |
value | the value to set |
IllegalArgumentException | if field is is null or not supported. |
---|
Adds the fields from another period.
period | the period to add from, not null |
---|
IllegalArgumentException | if an unsupported field's value is non-zero |
---|
Adds the fields from another period.
values | the array of values to update |
---|---|
period | the period to add from, not null |
IllegalArgumentException | if an unsupported field's value is non-zero |
---|
Validates a period type, converting nulls to a default value and checking the type is suitable for this instance.
type | the type to check, may be null |
---|
IllegalArgumentException | if the period type is invalid |
---|
Merges the fields from another period.
period | the period to add from, not null |
---|
IllegalArgumentException | if an unsupported field's value is non-zero |
---|
Merges the fields from another period.
values | the array of values to update |
---|---|
period | the period to add from, not null |
IllegalArgumentException | if an unsupported field's value is non-zero |
---|
Sets the value of a field in this period.
field | the field to set |
---|---|
value | the value to set |
IllegalArgumentException | if field is is null or not supported. |
---|
Sets the value of a field in this period.
values | the array of values to update |
---|---|
field | the field to set |
value | the value to set |
IllegalArgumentException | if field is null or not supported. |
---|
Sets all the fields of this period from another.
period | the period to copy from, not null |
---|
IllegalArgumentException | if an unsupported field's value is non-zero |
---|
Sets the eight standard the fields in one go.
years | amount of years in this period, which must be zero if unsupported |
---|---|
months | amount of months in this period, which must be zero if unsupported |
weeks | amount of weeks in this period, which must be zero if unsupported |
days | amount of days in this period, which must be zero if unsupported |
hours | amount of hours in this period, which must be zero if unsupported |
minutes | amount of minutes in this period, which must be zero if unsupported |
seconds | amount of seconds in this period, which must be zero if unsupported |
millis | amount of milliseconds in this period, which must be zero if unsupported |
IllegalArgumentException | if an unsupported field's value is non-zero |
---|
Sets the value of the field at the specifed index.
index | the index |
---|---|
value | the value to set |
IndexOutOfBoundsException | if the index is invalid |
---|
Sets the values of all fields.
values | the array of values |
---|