-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Open
Description
public static int getMonthLength(@NotNull final Date date) {
int year = get(date, Calendar.YEAR);
int month = get(date, Calendar.MONTH);
return getMonthLength(year, month);
}
public static int getMonthLength(int year, int month) {
if ((month < 1) || (month > 12)) {
throw new IllegalArgumentException("Invalid month: " + month);
}
if (month == 2) {
return isLeapYear(year) ? 29 : 28;
}
return MONTH_LENGTH[month];
}
因为
int month = get(date, Calendar.MONTH); 获取的月份应该是 0-11 之间
所以
结果是错误的
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels