Integer monthNum = monthCompare("2019-12-01");
/**
* 传入参数返回距离现在几个月
*/
public static Integer monthCompare(String oldTime){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date nowDate = new Date();
String nowDateStr = sdf.format(nowDate);
LocalDate from = LocalDate.parse(oldTime);
LocalDate to = LocalDate.parse(nowDateStr);
Integer months = Math.toIntExact(ChronoUnit.MONTHS.between(from, to));
return months;
}