Calculates the period between this year and another year in
terms of the specified unit.
This calculates the period between two years in terms of a single unit.
The start and end points are
this and the specified year.
The result will be negative if the end is before the start.
The
Temporal passed to this method must be a
Year.
For example, the period in decades between two year can be calculated
using
startYear.until(endYear, DECADES).
The calculation returns a whole number, representing the number of
complete units between the two years.
For example, the period in decades between 2012 and 2031
will only be one decade as it is one year short of two decades.
This method operates in association with
TemporalUnit#between.
The result of this method is a
long representing the amount of
the specified unit. By contrast, the result of
between is an
object that can be used directly in addition/subtraction:
long period = start.until(end, YEARS); // this method
dateTime.plus(YEARS.between(start, end)); // use in plus/minus
The calculation is implemented in this method for
ChronoUnit.
The units
YEARS,
DECADES,
CENTURIES,
MILLENNIA and
ERAS are supported.
Other
ChronoUnit values will throw an exception.
If the unit is not a
ChronoUnit, then the result of this method
is obtained by invoking
TemporalUnit.between(Temporal, Temporal)passing
this as the first argument and the input temporal as
the second argument.
This instance is immutable and unaffected by this method call.