ITemporal.Until(ITemporal, ITemporalUnit) Method

Definition

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

[Android.Runtime.Register("until", "(Ljava/time/temporal/Temporal;Ljava/time/temporal/TemporalUnit;)J", "GetUntil_Ljava_time_temporal_Temporal_Ljava_time_temporal_TemporalUnit_Handler:Java.Time.Temporal.ITemporalInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", 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", "GetUntil_Ljava_time_temporal_Temporal_Ljava_time_temporal_TemporalUnit_Handler:Java.Time.Temporal.ITemporalInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)>]
abstract member Until : Java.Time.Temporal.ITemporal * Java.Time.Temporal.ITemporalUnit -> int64

Parameters

endExclusive
ITemporal

the end temporal, exclusive, converted to be of the same type as this object, not null

unit
ITemporalUnit

the unit to measure the amount in, not null

Returns

the amount of time between this temporal object and the specified one in terms of the unit; positive if the specified object is later than this one, negative if it is earlier than this one

Attributes

Remarks

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

This calculates the amount of time between two temporal objects in terms of a single TemporalUnit. The start and end points are this and the specified temporal. The end point is converted to be of the same type as the start point if different. 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 startTime.until(endTime, HOURS).

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.

There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use TemporalUnit#between(Temporal, Temporal):

// these two lines are equivalent
              temporal = start.until(end, unit);
              temporal = unit.between(start, end);

The choice should be made based on which makes the code more readable.

For example, this method allows the number of days between two dates to be calculated:

long daysBetween = start.until(end, DAYS);
             // or alternatively
             long daysBetween = DAYS.between(start, end);

Java documentation for java.time.temporal.Temporal.until(java.time.temporal.Temporal, java.time.temporal.TemporalUnit).

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