Creates an instance.
Defend against malicious streams.
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>
The set of supported units.
The number of days.
The number of months.
The number of years.
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.
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.
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.
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.
Checks if all the supported units of this period are zero.
Checks if any of the supported units of this period are negative.
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.
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.
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.
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.
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.
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.
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.
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