📜  java localdate 减去两个日期 - Java 代码示例

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

代码示例1
@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);
}