📜  java 8 datediff in days - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:20.255000             🧑  作者: Mango

代码示例2
@Test
public void givenTwoDatesInJava8_whenDifferentiating_thenWeGetSix() {
    LocalDate now = LocalDate.now();
    LocalDate sixDaysBehind = now.minusDays(6);
 
    Period period = Period.between(now, sixDaysBehind);
    int diff = period.getDays();
 
    assertEquals(diff, 6);
}