Java计算两个时间之间的时间差月份
String text1 = "2022-07-01";
Temporal temporal1 = LocalDate.parse(text1);
String text2 = "2022-09-01";
Temporal temporal2 = LocalDate.parse(text2);
// 方法返回为相差月份
long l = ChronoUnit.MONTHS.between(temporal1, temporal2);
System.out.println(l);