You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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];
}
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 之间
所以
结果是错误的
The text was updated successfully, but these errors were encountered: