计算两个日期之间的时间差,只能是年月日
public static void main(String[] args) throws java.lang.Exception {
//LocalDate localDate = LocalDate.now(); //当前时间
String[] str="2016-08-1".split("-");
LocalDate localDate = LocalDate.of(2020,8,6); //当前时间
LocalDate birthday = LocalDate.of(Integer.parseInt(str[0]),Integer.parseInt(str[1]),Integer.parseInt(str[2]));//要计算的时间
Period betweenDate = Period.between(birthday, localDate); //计算时间间隔
System.out.println("year:"+betweenDate.getYears());
System.out.println("months:"+betweenDate.getMonths());
System.out.println("day:"+betweenDate.getDays());
}