package com.logicbig.example.localdatetime;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
public class UntilExample {
public static void main (String... args) {
LocalDateTime dt = LocalDateTime.of(1999, 1, 20,
20, 10, 30);
LocalDateTime dt2 = LocalDateTime.of(2005, 10, 1,
10, 5);
long l = dt.until(dt2, ChronoUnit.DAYS);
System.out.printf("DAYS between %s and %s => %s%n", dt, dt2, l);
l = dt.until(dt2, ChronoUnit.HOURS);
System.out.printf("HOURS between %s and %s => %s%n", dt, dt2, l);
l = dt.until(dt2, ChronoUnit.MONTHS);
System.out.printf("MONTHS between %s and %s => %s%n", dt, dt2, l);
l = dt.until(dt2, ChronoUnit.YEARS);
System.out.printf("YEARS between %s and %s => %s%n", dt, dt2, l);
}
}