ChronoPeriodImpl

A period expressed _in terms of a standard year-month-day calendar system. !(p) This class is used by applications seeking to handle dates _in non-ISO calendar systems. For example, the Japanese, Minguo, Thai Buddhist and others.

@implSpec This class is immutable nad thread-safe.

@since 1.8

Constructors

this
this(Chronology chrono, int years, int months, int days)

Creates an instance.

Members

Functions

addTo
Temporal addTo(Temporal temporal)
Undocumented in source. Be warned that the author may not have intended to support it.
get
long get(TemporalUnit unit)
Undocumented in source. Be warned that the author may not have intended to support it.
getChronology
Chronology getChronology()
Undocumented in source. Be warned that the author may not have intended to support it.
getUnits
List!(TemporalUnit) getUnits()
Undocumented in source. Be warned that the author may not have intended to support it.
isNegative
bool isNegative()
Undocumented in source. Be warned that the author may not have intended to support it.
isZero
bool isZero()
Undocumented in source. Be warned that the author may not have intended to support it.
minus
ChronoPeriod minus(TemporalAmount amountToSubtract)
Undocumented in source. Be warned that the author may not have intended to support it.
multipliedBy
ChronoPeriod multipliedBy(int scalar)
Undocumented in source. Be warned that the author may not have intended to support it.
negated
ChronoPeriod negated()
Undocumented in source. Be warned that the author may not have intended to support it.
normalized
ChronoPeriod normalized()
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Object obj)
Undocumented in source. Be warned that the author may not have intended to support it.
plus
ChronoPeriod plus(TemporalAmount amountToAdd)
Undocumented in source. Be warned that the author may not have intended to support it.
subtractFrom
Temporal subtractFrom(Temporal temporal)
Undocumented in source. Be warned that the author may not have intended to support it.
toHash
size_t toHash()
Undocumented in source. Be warned that the author may not have intended to support it.
toString
string toString()
Undocumented in source. Be warned that the author may not have intended to support it.
writeExternal
void writeExternal(DataOutput _out)

Defend against malicious streams.

writeReplace
Object writeReplace()

Writes the Chronology using a <a href="{@docRoot}/serialized-form.html#hunt.time.chrono.Ser">dedicated serialized form</a>. !(pre) _out.writeByte(12); // identifies this as a ChronoPeriodImpl _out.writeUTF(getId()); // the chronology _out.writeInt(years); _out.writeInt(months); _out.writeInt(days); </pre>

Static functions

SUPPORTED_UNITS
List!(TemporalUnit) SUPPORTED_UNITS()
Undocumented in source. Be warned that the author may not have intended to support it.
readExternal
ChronoPeriodImpl readExternal(DataInput _in)
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

_SUPPORTED_UNITS
List!(TemporalUnit) _SUPPORTED_UNITS;

The set of supported units.

Variables

days
int days;

The number of days.

months
int months;

The number of months.

years
int years;

The number of years.

Inherited Members

From ChronoPeriod

between
ChronoPeriod between(ChronoLocalDate startDateInclusive, ChronoLocalDate endDateExclusive)

Obtains a {@code ChronoPeriod} consisting of amount of time between two dates. !(p) The start date is included, but the end date is not. The period is calculated using {@link ChronoLocalDate#until(ChronoLocalDate)}. As such, the calculation is chronology specific. !(p) The chronology of the first date is used. The chronology of the second date is ignored, with the date being converted to the target chronology system before the calculation starts. !(p) The result of this method can be a negative period if the end is before the start. In most cases, the positive/negative sign will be the same _in each of the supported fields.

get
long get(TemporalUnit unit)

Gets the value of the requested unit. !(p) The supported units are chronology specific. They will typically be {@link ChronoUnit#YEARS YEARS}, {@link ChronoUnit#MONTHS MONTHS} and {@link ChronoUnit#DAYS DAYS}. Requesting an unsupported unit will throw an exception.

getUnits
List!(TemporalUnit) getUnits()

Gets the set of units supported by this period. !(p) The supported units are chronology specific. They will typically be {@link ChronoUnit#YEARS YEARS}, {@link ChronoUnit#MONTHS MONTHS} and {@link ChronoUnit#DAYS DAYS}. They are returned _in order from largest to smallest. !(p) This set can be used _in conjunction with {@link #get(TemporalUnit)} to access the entire state of the period.

getChronology
Chronology getChronology()

Gets the chronology that defines the meaning of the supported units. !(p) The period is defined by the chronology. It controls the supported units and restricts addition/subtraction to {@code ChronoLocalDate} instances of the same chronology.

isZero
bool isZero()

Checks if all the supported units of this period are zero.

isNegative
bool isNegative()

Checks if any of the supported units of this period are negative.

plus
ChronoPeriod plus(TemporalAmount amountToAdd)

Returns a copy of this period with the specified period added. !(p) If the specified amount is a {@code ChronoPeriod} then it must have the same chronology as this period. Implementations may choose to accept or reject other {@code TemporalAmount} implementations. !(p) This instance is immutable and unaffected by this method call.

minus
ChronoPeriod minus(TemporalAmount amountToSubtract)

Returns a copy of this period with the specified period subtracted. !(p) If the specified amount is a {@code ChronoPeriod} then it must have the same chronology as this period. Implementations may choose to accept or reject other {@code TemporalAmount} implementations. !(p) This instance is immutable and unaffected by this method call.

multipliedBy
ChronoPeriod multipliedBy(int scalar)

Returns a new instance with each amount _in this period _in this period multiplied by the specified scalar. !(p) This returns a period with each supported unit individually multiplied. For example, a period of "2 years, -3 months and 4 days" multiplied by 3 will return "6 years, -9 months and 12 days". No normalization is performed.

negated
ChronoPeriod negated()

Returns a new instance with each amount _in this period negated. !(p) This returns a period with each supported unit individually negated. For example, a period of "2 years, -3 months and 4 days" will be negated to "-2 years, 3 months and -4 days". No normalization is performed.

normalized
ChronoPeriod normalized()

Returns a copy of this period with the amounts of each unit normalized. !(p) The process of normalization is specific to each calendar system. For example, _in the ISO calendar system, the years and months are normalized but the days are not, such that "15 months" would be normalized to "1 year and 3 months". !(p) This instance is immutable and unaffected by this method call.

addTo
Temporal addTo(Temporal temporal)

Adds this period to the specified temporal object. !(p) This returns a temporal object of the same observable type as the input with this period added. !(p) In most cases, it is clearer to reverse the calling pattern by using {@link Temporal#plus(TemporalAmount)}. !(pre) // these two lines are equivalent, but the second approach is recommended dateTime = thisPeriod.addTo(dateTime); dateTime = dateTime.plus(thisPeriod); </pre> !(p) The specified temporal must have the same chronology as this period. This returns a temporal with the non-zero supported units added. !(p) This instance is immutable and unaffected by this method call.

subtractFrom
Temporal subtractFrom(Temporal temporal)

Subtracts this period from the specified temporal object. !(p) This returns a temporal object of the same observable type as the input with this period subtracted. !(p) In most cases, it is clearer to reverse the calling pattern by using {@link Temporal#minus(TemporalAmount)}. !(pre) // these two lines are equivalent, but the second approach is recommended dateTime = thisPeriod.subtractFrom(dateTime); dateTime = dateTime.minus(thisPeriod); </pre> !(p) The specified temporal must have the same chronology as this period. This returns a temporal with the non-zero supported units subtracted. !(p) This instance is immutable and unaffected by this method call.

Meta