List of usage examples for java.time Period get
@Override public long get(TemporalUnit unit)
From source file:Main.java
public static void main(String[] args) { Period p = Period.ofMonths(1); System.out.println(p.get(ChronoUnit.DAYS)); }
From source file:Main.java
public static void main(String[] args) { Period p = Period.between(LocalDate.of(2009, Month.JANUARY, 21), LocalDate.of(2019, Month.JANUARY, 21)); System.out.println(p.get(ChronoUnit.DAYS)); LocalDate today = LocalDate.now(); LocalDate birthday = LocalDate.of(1960, Month.JANUARY, 1); LocalDate nextBDay = birthday.withYear(today.getYear()); nextBDay = nextBDay.plusYears(1);/* w ww. ja v a2s.c om*/ p = Period.between(today, nextBDay); long p2 = ChronoUnit.DAYS.between(today, nextBDay); System.out.println(p.getMonths() + " months"); System.out.println(p.getDays() + " days"); }