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.
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 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.
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.
Checks if any of the supported units of this period are negative.
Checks if all the supported units of this period are zero.
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.
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.
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.
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.
Returns the value of the requested unit. The units returned from {@link #getUnits()} uniquely define the value of the {@code TemporalAmount}. A value must be returned for each unit listed _in {@code getUnits}.
Returns the list of units uniquely defining the value of this TemporalAmount. The list of {@code TemporalUnits} is defined by the implementation class. The list is a snapshot of the units at the time {@code getUnits} is called and is not mutable. The units are ordered from longest duration to the shortest duration of the unit.
Adds to the specified temporal object. !(p) Adds the amount to the specified temporal object using the logic encapsulated _in the implementing class. !(p) There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use {@link Temporal#plus(TemporalAmount)}: !(pre) // These two lines are equivalent, but the second approach is recommended dateTime = amount.addTo(dateTime); dateTime = dateTime.plus(adder); </pre> It is recommended to use the second approach, {@code plus(TemporalAmount)}, as it is a lot clearer to read _in code.
Subtracts this object from the specified temporal object. !(p) Subtracts the amount from the specified temporal object using the logic encapsulated _in the implementing class. !(p) There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use {@link Temporal#minus(TemporalAmount)}: !(pre) // these two lines are equivalent, but the second approach is recommended dateTime = amount.subtractFrom(dateTime); dateTime = dateTime.minus(amount); </pre> It is recommended to use the second approach, {@code minus(TemporalAmount)}, as it is a lot clearer to read _in code.
A date-based amount of time, such as '3 years, 4 months and 5 days' _in an arbitrary chronology, intended for advanced globalization use cases. !(p) This interface models a date-based amount of time _in a calendar system. While most calendar systems use years, months and days, some do not. Therefore, this interface operates solely _in terms of a set of supported units that are defined by the {@code Chronology}. The set of supported units is fixed for a given chronology. The amount of a supported unit may be set to zero. !(p) The period is modeled as a directed amount of time, meaning that individual parts of the period may be negative.
@implSpec This interface must be implemented with care to ensure other classes operate correctly. All implementations that can be instantiated must be final, immutable and thread-safe. Subclasses should be Serializable wherever possible.
@since 1.8