Instant.Until(ITemporal, ITemporalUnit) Method

Definition

Calculates the amount of time until another instant in terms of the specified unit.

[Android.Runtime.Register("until", "(Ljava/time/temporal/Temporal;Ljava/time/temporal/TemporalUnit;)J", "", ApiSince=26)]
public long Until(Java.Time.Temporal.ITemporal? endExclusive, Java.Time.Temporal.ITemporalUnit? unit);
[<Android.Runtime.Register("until", "(Ljava/time/temporal/Temporal;Ljava/time/temporal/TemporalUnit;)J", "", ApiSince=26)>]
abstract member Until : Java.Time.Temporal.ITemporal * Java.Time.Temporal.ITemporalUnit -> int64
override this.Until : Java.Time.Temporal.ITemporal * Java.Time.Temporal.ITemporalUnit -> int64

Parameters

endExclusive
ITemporal

Temporal: the end date, exclusive, which is converted to an Instant, not null

unit
ITemporalUnit

TemporalUnit: the unit to measure the amount in, not null

Returns

the amount of time between this instant and the end instant

Implements

Attributes

Remarks

Calculates the amount of time until another instant in terms of the specified unit. This calculates the amount of time between two Instant objects in terms of a single TemporalUnit. The start and end points are this and the specified instant. The result will be negative if the end is before the start. The calculation returns a whole number, representing the number of complete units between the two instants. The Temporal passed to this method is converted to a Instant using from(TemporalAccessor). For example, the amount in seconds between two dates can be calculated using startInstant.until(endInstant, SECONDS). There are two equivalent ways of using this method. The first is to invoke this method. The second is to use TemporalUnit.between(Temporal,Temporal): The choice should be made based on which makes the code more readable. The calculation is implemented in this method for ChronoUnit. The units NANOS, MICROS, MILLIS, SECONDS, MINUTES, HOURS, HALF_DAYS and 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 converted input temporal as the second argument. This instance is immutable and unaffected by this method call.

Throws: ArithmeticException if numeric overflow occurs

Throws: DateTimeException if the amount cannot be calculated, or the end temporal cannot be converted to an Instant

Throws: UnsupportedTemporalTypeException if the unit is not supported

Android reference for java.time.Instant.until.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to