计算两个LocalDate之间的时间间隔
记录收藏下,这样就可以计算不同维度的时间间隔,
程序示例:
public static void main(String[] args) { LocalDate start = LocalDate.parse("2018-09-01");
LocalDate end = LocalDate.parse("2018-09-30");
long year = start.until(end, ChronoUnit.YEARS);
long month = start.until(end, ChronoUnit.MONTHS);
long days = start.until(end, ChronoUnit.DAYS);
System.out.println("间隔:" + year + "年");
System.out.println("间隔:" + month + "月");
System.out.println("间隔:" + days + "天");
System.out.println(ChronoUnit.MONTHS.between(start,end));
}
以上是 计算两个LocalDate之间的时间间隔 的全部内容, 来源链接: utcz.com/z/518917.html