Calculates the amount of time between two temporal objects.
!(p)
This calculates the amount _in terms of this unit. The start and end
points are supplied as temporal objects and must be of compatible types.
The implementation will convert the second type to be an instance of the
first type before the calculating the amount.
The result will be negative if the end is before the start.
For example, the amount _in hours between two temporal objects can be
calculated using {@code HOURS.between(startTime, endTime)}.
!(p)
The calculation returns a whole number, representing the number of
complete units between the two temporals.
For example, the amount _in hours between the times 11:30 and 13:29
will only be one hour as it is one minute short of two hours.
!(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#until(Temporal, TemporalUnit)}:
!(pre)
// these two lines are equivalent
between = thisUnit.between(start, end);
between = start.until(end, thisUnit);
</pre>
The choice should be made based on which makes the code more readable.
!(p)
For example, this method allows the number of days between two dates to
be calculated:
!(pre)
long daysBetween = DAYS.between(start, end);
// or alternatively
long daysBetween = start.until(end, DAYS);
</pre>
!(p)
Implementations should perform any queries or calculations using the units
available _in {@link ChronoUnit} or the fields available _in {@link ChronoField}.
If the unit is not supported an {@code UnsupportedTemporalTypeException} must be thrown.
Implementations must not alter the specified temporal objects.
@implSpec
Implementations must begin by checking to if the two temporals have the
same type using {@code getClass()}. If they do not, then the result must be
obtained by calling {@code temporal1Inclusive.until(temporal2Exclusive, this)}.
@param temporal1Inclusive the base temporal object, not null
@param temporal2Exclusive the other temporal object, exclusive, not null
@return the amount of time between temporal1Inclusive and temporal2Exclusive
_in terms of this unit; positive if temporal2Exclusive is later than
temporal1Inclusive, negative if earlier
@throws DateTimeException if the amount cannot be calculated, or the end
temporal cannot be converted to the same type as the start temporal
@throws UnsupportedTemporalTypeException if the unit is not supported by the temporal
@throws ArithmeticException if numeric overflow occurs
Calculates the amount of time between two temporal objects. !(p) This calculates the amount _in terms of this unit. The start and end points are supplied as temporal objects and must be of compatible types. The implementation will convert the second type to be an instance of the first type before the calculating the amount. The result will be negative if the end is before the start. For example, the amount _in hours between two temporal objects can be calculated using {@code HOURS.between(startTime, endTime)}. !(p) The calculation returns a whole number, representing the number of complete units between the two temporals. For example, the amount _in hours between the times 11:30 and 13:29 will only be one hour as it is one minute short of two hours. !(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#until(Temporal, TemporalUnit)}: !(pre) // these two lines are equivalent between = thisUnit.between(start, end); between = start.until(end, thisUnit); </pre> The choice should be made based on which makes the code more readable. !(p) For example, this method allows the number of days between two dates to be calculated: !(pre) long daysBetween = DAYS.between(start, end); // or alternatively long daysBetween = start.until(end, DAYS); </pre> !(p) Implementations should perform any queries or calculations using the units available _in {@link ChronoUnit} or the fields available _in {@link ChronoField}. If the unit is not supported an {@code UnsupportedTemporalTypeException} must be thrown. Implementations must not alter the specified temporal objects.
@implSpec Implementations must begin by checking to if the two temporals have the same type using {@code getClass()}. If they do not, then the result must be obtained by calling {@code temporal1Inclusive.until(temporal2Exclusive, this)}.
@param temporal1Inclusive the base temporal object, not null @param temporal2Exclusive the other temporal object, exclusive, not null @return the amount of time between temporal1Inclusive and temporal2Exclusive _in terms of this unit; positive if temporal2Exclusive is later than temporal1Inclusive, negative if earlier @throws DateTimeException if the amount cannot be calculated, or the end temporal cannot be converted to the same type as the start temporal @throws UnsupportedTemporalTypeException if the unit is not supported by the temporal @throws ArithmeticException if numeric overflow occurs