Instant until(Temporal endExclusive, TemporalUnit unit) example
Description
Instant until(Temporal endExclusive, TemporalUnit unit)
calculates the amount of time until another instant 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.Instant;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;
/*from ww w. ja v a 2 s. co m*/
public class Main {
public static void main(String[] args) {
Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
ZonedDateTime l = ZonedDateTime.now();
System.out.println(instant.until(l,ChronoUnit.DAYS));
}
}
The code above generates the following result.