Calculates the period between this time and another time in
terms of the specified unit.
This calculates the period between two times in terms of a single unit.
The start and end points are
this and the specified time.
The result will be negative if the end is before the start.
The
Temporal passed to this method must be a
LocalTime.
For example, the period in hours between two times can be calculated
using
startTime.until(endTime, HOURS).
The calculation returns a whole number, representing the number of
complete units between the two times.
For example, the period in hours between 11:30 and 13:29 will only
be one hour as it is one minute short of two hours.
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, HOURS); // this method
dateTime.plus(HOURS.between(start, end)); // use in plus/minus
The calculation is implemented in this method for
ChronoUnit.
The units
NANOS,
MICROS,
MILLIS,
SECONDS,
MINUTES,
HOURS and
HALF_DAYS 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.