LocalDateTime until(Temporal endExclusive, TemporalUnit unit)
calculates the amount of time until another date-time in terms of the specified unit.
The following units are supported.
until
has the following syntax.
public long until(Temporal endExclusive, TemporalUnit unit)
The following example shows how to use until
.
import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; //from w ww . j ava2s . c o m public class Main { public static void main(String[] args) { LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00); long l = a.until(LocalDateTime.now(),ChronoUnit.DAYS); System.out.println(l); } }
The code above generates the following result.