1LocalDate dateBefore;
2LocalDate dateAfter;
3long daysBetween = DAYS.between(dateBefore, dateAfter);
1@Test
2public void givenTwoDatesInJava8_whenDifferentiating_thenWeGetSix() {
3 LocalDate now = LocalDate.now();
4 LocalDate sixDaysBehind = now.minusDays(6);
5
6 Period period = Period.between(now, sixDaysBehind);
7 int diff = period.getDays();
8
9 assertEquals(diff, 6);
10}
11