Java的根据年月计算月份有多少天
public class MonthDaysUtil {
//获取月份的天数
public static int getMonthDays(int year, int month) {
if (month == 2) {
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
return 29;
} else {
return 28;
}
} else if (month == 4 || month == 6 || month == 9 || month == 11) {
return 30;
} else {
return 31;
}
}
}