List of usage examples for java.time LocalDate until
@Override public long until(Temporal endExclusive, TemporalUnit unit)
From source file:Main.java
public static void main(String[] args) { LocalDate a = LocalDate.of(2014, 6, 30); long p = a.until(LocalDate.of(2015, 6, 30), ChronoUnit.MONTHS); System.out.println(p);/*from w w w.j a v a 2 s .c o m*/ }
From source file:Main.java
public static void main(String[] args) { LocalDate startEmployment = LocalDate.of(2011, Month.FEBRUARY, 1); LocalDate today = LocalDate.now(); long numberOfDays = startEmployment.until(today, ChronoUnit.DAYS); System.out.println(String.format("%d", numberOfDays)); }
From source file:Main.java
public static void main(String[] args) { LocalDate ld1 = LocalDate.of(2014, Month.JANUARY, 7); LocalDate ld2 = LocalDate.of(2014, Month.MAY, 18); LocalTime lt1 = LocalTime.of(7, 0); LocalTime lt2 = LocalTime.of(9, 30); long days = ld1.until(ld2, ChronoUnit.DAYS); System.out.println(days);/*from ww w. j a v a 2 s . c o m*/ long hours = lt1.until(lt2, ChronoUnit.HOURS); System.out.println(hours); long minutes = lt1.until(lt2, ChronoUnit.MINUTES); System.out.println(minutes); }
From source file:com.clearprecision.microservices.reference.jetty.service.BirthdayService.java
public Birthday getNumberOfDaysUntilBirthday(Integer day, Integer month) { Birthday bd = new Birthday(); LocalDate date = LocalDate.now(); LocalDate birthday = LocalDate.of(date.getYear(), month, day); long days = date.until(birthday, ChronoUnit.DAYS); bd.setDate(days + " days until your birthday"); return bd;/* w w w . j av a 2 s . c om*/ }