java获取一个月最后一天## 标题
/**
* 获取一个月最后一天
* @param yearMonth 2022-12
* @return
*/
public static Integer getMonthLastDay(String yearMonth){
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR,Integer.parseInt(yearMonth.split("-")[0]));
// //获取月份,0表示1月份
cal.set(Calendar.MONTH,Integer.parseInt(yearMonth.split("-")[1]) - 1);
cal.set(Calendar.DAY_OF_MONTH,1);
System.out.println(format0.format(cal.getTime()));
int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
return lastDay;
}