代码是这样的:
LocalDate localDateStart=LocalDate.of(2018,3,1);
LocalDate localDateEnd=LocalDate.of(2018,4,2);
Period period=Period.between(localDateStart,localDateEnd);
long years=period.getYears();
long months=period.getMonths();
long days=period.getDays();
System.out.println("year="+years+",month="+months+",days="+days);
//打印结果 year=0,month=1,days=1
修改开始日期到18年2月28号
LocalDate localDateStart=LocalDate.of(2018,2,28);
LocalDate localDateEnd=LocalDate.of(2018,4,2);
Period period=Period.between(localDateStart,localDateEnd);
long years=period.getYears();
long months=period.getMonths();
long days=period.getDays();
System.out.println("year="+years+",month="+months+",days="+days);
//打印结果: year=0,month=1,days=5
这算是个bug吗?
先记录,未解决。