public abstract class BasePeriod extends AbstractPeriod implements ReadablePeriod, java.io.Serializable
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.
Modifier and Type | Method and Description |
---|---|
PeriodType |
getPeriodType()
Gets the period type.
|
int |
getValue(int index)
Gets the value at the specified index.
|
Duration |
toDurationFrom(ReadableInstant startInstant)
Gets the total millisecond duration of this period relative to a start instant.
|
Duration |
toDurationTo(ReadableInstant endInstant)
Gets the total millisecond duration of this period relative to an
end instant.
|
equals, get, getFieldType, getFieldTypes, getValues, hashCode, indexOf, isSupported, size, toMutablePeriod, toPeriod, toString, toString
equals, get, getFieldType, hashCode, isSupported, size, toMutablePeriod, toPeriod, toString
public PeriodType getPeriodType()
getPeriodType
in interface ReadablePeriod
public int getValue(int index)
getValue
in interface ReadablePeriod
index
- the index to retrievejava.lang.IndexOutOfBoundsException
- if the index is invalidpublic Duration toDurationFrom(ReadableInstant startInstant)
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 durationjava.lang.ArithmeticException
- if the millis exceeds the capacity of the durationpublic Duration toDurationTo(ReadableInstant endInstant)
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 durationjava.lang.ArithmeticException
- if the millis exceeds the capacity of the durationCopyright © 2010 - 2020 Adobe. All Rights Reserved