# ChronoPeriod

public interface **ChronoPeriod** implements [TemporalAmount](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalAmount.html)

|---|---|---|
| Known Indirect Subclasses [Period](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/Period.html) |---|---| | [Period](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/Period.html) | A date-based amount of time in the ISO-8601 calendar system, such as '2 years, 3 months and 4 days'. | |||

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.


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 `Chronology`.
The set of supported units is fixed for a given chronology.
The amount of a supported unit may be set to zero.


The period is modeled as a directed amount of time, meaning that individual
parts of the period may be negative.

### Public Method Summary

|---|---|
| abstract [Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html) | [addTo](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#addTo(java.time.temporal.Temporal))([Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html) temporal) Adds this period to the specified temporal object. |
| static [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html) | [between](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#between(java.time.chrono.ChronoLocalDate,%20java.time.chrono.ChronoLocalDate))([ChronoLocalDate](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoLocalDate.html) startDateInclusive, [ChronoLocalDate](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoLocalDate.html) endDateExclusive) Obtains a `ChronoPeriod` consisting of amount of time between two dates. |
| abstract boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Checks if this period is equal to another period, including the chronology. |
| abstract long | [get](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#get(java.time.temporal.TemporalUnit))([TemporalUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalUnit.html) unit) Gets the value of the requested unit. |
| abstract [Chronology](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/Chronology.html) | [getChronology](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#getChronology())() Gets the chronology that defines the meaning of the supported units. |
| abstract [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[TemporalUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalUnit.html)\> | [getUnits](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#getUnits())() Gets the set of units supported by this period. |
| abstract int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#hashCode())() A hash code for this period. |
| boolean | [isNegative](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#isNegative())() Checks if any of the supported units of this period are negative. |
| boolean | [isZero](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#isZero())() Checks if all the supported units of this period are zero. |
| abstract [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html) | [minus](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#minus(java.time.temporal.TemporalAmount))([TemporalAmount](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalAmount.html) amountToSubtract) Returns a copy of this period with the specified period subtracted. |
| abstract [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html) | [multipliedBy](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#multipliedBy(int))(int scalar) Returns a new instance with each amount in this period in this period multiplied by the specified scalar. |
| [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html) | [negated](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#negated())() Returns a new instance with each amount in this period negated. |
| abstract [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html) | [normalized](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#normalized())() Returns a copy of this period with the amounts of each unit normalized. |
| abstract [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html) | [plus](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#plus(java.time.temporal.TemporalAmount))([TemporalAmount](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalAmount.html) amountToAdd) Returns a copy of this period with the specified period added. |
| abstract [Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html) | [subtractFrom](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#subtractFrom(java.time.temporal.Temporal))([Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html) temporal) Subtracts this period from the specified temporal object. |
| abstract [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#toString())() Outputs this period as a `String`. |

### Inherited Method Summary

From interface [java.time.temporal.TemporalAmount](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalAmount.html)

|---|---|
| abstract [Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html) | [addTo](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalAmount.html#addTo(java.time.temporal.Temporal))([Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html) temporal) Adds to the specified temporal object. |
| abstract long | [get](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalAmount.html#get(java.time.temporal.TemporalUnit))([TemporalUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalUnit.html) unit) Returns the value of the requested unit. |
| abstract [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[TemporalUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalUnit.html)\> | [getUnits](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalAmount.html#getUnits())() Returns the list of units uniquely defining the value of this TemporalAmount. |
| abstract [Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html) | [subtractFrom](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalAmount.html#subtractFrom(java.time.temporal.Temporal))([Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html) temporal) Subtracts this object from the specified temporal object. |

## Public Methods

#### public abstract [Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html)
**addTo**
([Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html) temporal)

Adds this period to the specified temporal object.


This returns a temporal object of the same observable type as the input
with this period added.


In most cases, it is clearer to reverse the calling pattern by using
`https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html#plus(java.time.temporal.TemporalAmount)`.

```
   // these two lines are equivalent, but the second approach is recommended
   dateTime = thisPeriod.addTo(dateTime);
   dateTime = dateTime.plus(thisPeriod);
 
```


The specified temporal must have the same chronology as this period.
This returns a temporal with the non-zero supported units added.


This instance is immutable and unaffected by this method call.

##### Parameters

| temporal | the temporal object to adjust, not null |
|---|---|

##### Returns

- an object of the same type with the adjustment made, not null

##### Throws

| [DateTimeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/DateTimeException.html) | if unable to add |
| [ArithmeticException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ArithmeticException.html) | if numeric overflow occurs |
|---|---|

#### public static [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html)
**between**
([ChronoLocalDate](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoLocalDate.html) startDateInclusive, [ChronoLocalDate](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoLocalDate.html) endDateExclusive)

Obtains a `ChronoPeriod` consisting of amount of time between two dates.


The start date is included, but the end date is not.
The period is calculated using `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoLocalDate.html#until(java.time.chrono.ChronoLocalDate)`.
As such, the calculation is chronology specific.


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.


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.

##### Parameters

| startDateInclusive | the start date, inclusive, specifying the chronology of the calculation, not null |
| endDateExclusive | the end date, exclusive, in any chronology, not null |
|---|---|

##### Returns

- the period between this date and the end date, not null

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoLocalDate.html#until(java.time.chrono.ChronoLocalDate)`

#### public abstract boolean
**equals**
([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj)

Checks if this period is equal to another period, including the chronology.


Compares this period with another ensuring that the type, each amount and
the chronology are the same.
Note that this means that a period of "15 Months" is not equal to a period
of "1 Year and 3 Months".

##### Parameters

| obj | the object to check, null returns false |
|---|---|

##### Returns

- true if this is equal to the other period

#### public abstract long
**get**
([TemporalUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalUnit.html) unit)

Gets the value of the requested unit.


The supported units are chronology specific.
They will typically be `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/ChronoUnit.html#YEARS`,
`https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/ChronoUnit.html#MONTHS` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/ChronoUnit.html#DAYS`.
Requesting an unsupported unit will throw an exception.

##### Parameters

| unit | the `TemporalUnit` for which to return the value |
|---|---|

##### Returns

- the long value of the unit

##### Throws

| [DateTimeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/DateTimeException.html) | if the unit is not supported |
| [UnsupportedTemporalTypeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/UnsupportedTemporalTypeException.html) | if the unit is not supported |
|---|---|

#### public abstract [Chronology](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/Chronology.html)
**getChronology**
()

Gets the chronology that defines the meaning of the supported units.


The period is defined by the chronology.
It controls the supported units and restricts addition/subtraction
to `ChronoLocalDate` instances of the same chronology.

##### Returns

- the chronology defining the period, not null

#### public abstract [List](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/List.html)\<[TemporalUnit](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalUnit.html)\>
**getUnits**
()

Gets the set of units supported by this period.


The supported units are chronology specific.
They will typically be `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/ChronoUnit.html#YEARS`,
`https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/ChronoUnit.html#MONTHS` and `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/ChronoUnit.html#DAYS`.
They are returned in order from largest to smallest.


This set can be used in conjunction with `https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html#get(java.time.temporal.TemporalUnit)`
to access the entire state of the period.

##### Returns

- a list containing the supported units, not null

#### public abstract int
**hashCode**
()

A hash code for this period.

##### Returns

- a suitable hash code

#### public boolean
**isNegative**
()

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

##### Returns

- true if any unit of this period is negative

#### public boolean
**isZero**
()

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

##### Returns

- true if this period is zero-length

#### public abstract [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html)
**minus**
([TemporalAmount](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalAmount.html) amountToSubtract)

Returns a copy of this period with the specified period subtracted.


If the specified amount is a `ChronoPeriod` then it must have
the same chronology as this period. Implementations may choose to
accept or reject other `TemporalAmount` implementations.


This instance is immutable and unaffected by this method call.

##### Parameters

| amountToSubtract | the period to subtract, not null |
|---|---|

##### Returns

- a `ChronoPeriod` based on this period with the requested period subtracted, not null

##### Throws

| [ArithmeticException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ArithmeticException.html) | if numeric overflow occurs |
|---|---|

#### public abstract [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html)
**multipliedBy**
(int scalar)

Returns a new instance with each amount in this period in this period
multiplied by the specified scalar.


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.

##### Parameters

| scalar | the scalar to multiply by, not null |
|---|---|

##### Returns

- a `ChronoPeriod` based on this period with the amounts multiplied by the scalar, not null

##### Throws

| [ArithmeticException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ArithmeticException.html) | if numeric overflow occurs |
|---|---|

#### public [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html)
**negated**
()

Returns a new instance with each amount in this period negated.


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 `ChronoPeriod` based on this period with the amounts negated, not null

##### Throws

| [ArithmeticException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ArithmeticException.html) | if numeric overflow occurs, which only happens if one of the units has the value `Long.MIN_VALUE` |
|---|---|

#### public abstract [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html)
**normalized**
()

Returns a copy of this period with the amounts of each unit normalized.


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".


This instance is immutable and unaffected by this method call.

##### Returns

- a `ChronoPeriod` based on this period with the amounts of each unit normalized, not null

##### Throws

| [ArithmeticException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ArithmeticException.html) | if numeric overflow occurs |
|---|---|

#### public abstract [ChronoPeriod](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/chrono/ChronoPeriod.html)
**plus**
([TemporalAmount](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/TemporalAmount.html) amountToAdd)

Returns a copy of this period with the specified period added.


If the specified amount is a `ChronoPeriod` then it must have
the same chronology as this period. Implementations may choose to
accept or reject other `TemporalAmount` implementations.


This instance is immutable and unaffected by this method call.

##### Parameters

| amountToAdd | the period to add, not null |
|---|---|

##### Returns

- a `ChronoPeriod` based on this period with the requested period added, not null

##### Throws

| [ArithmeticException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ArithmeticException.html) | if numeric overflow occurs |
|---|---|

#### public abstract [Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html)
**subtractFrom**
([Temporal](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html) temporal)

Subtracts this period from the specified temporal object.


This returns a temporal object of the same observable type as the input
with this period subtracted.


In most cases, it is clearer to reverse the calling pattern by using
`https://developers.google.com/j2objc/javadoc/jre/reference/java/time/temporal/Temporal.html#minus(java.time.temporal.TemporalAmount)`.

```
   // these two lines are equivalent, but the second approach is recommended
   dateTime = thisPeriod.subtractFrom(dateTime);
   dateTime = dateTime.minus(thisPeriod);
 
```


The specified temporal must have the same chronology as this period.
This returns a temporal with the non-zero supported units subtracted.


This instance is immutable and unaffected by this method call.

##### Parameters

| temporal | the temporal object to adjust, not null |
|---|---|

##### Returns

- an object of the same type with the adjustment made, not null

##### Throws

| [DateTimeException](https://developers.google.com/j2objc/javadoc/jre/reference/java/time/DateTimeException.html) | if unable to subtract |
| [ArithmeticException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ArithmeticException.html) | if numeric overflow occurs |
|---|---|

#### public abstract [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Outputs this period as a `String`.


The output will include the period amounts and chronology.

##### Returns

- a string representation of this period, not null