Java Date Time - OffsetTime until(Temporal endExclusive, TemporalUnit unit) example








OffsetTime until(Temporal endExclusive, TemporalUnit unit) calculates the amount of time until another time in terms of the specified unit.

Syntax

until has the following syntax.

public long until(Temporal endExclusive,  TemporalUnit unit)

Example

The following example shows how to use until.

import java.time.OffsetTime;
import java.time.temporal.ChronoUnit;
/*from  www.  ja  va  2 s .c o m*/
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    long n = m.until(OffsetTime.now(),ChronoUnit.MINUTES);
    System.out.println(n);

  }
}

The code above generates the following result.