This commit is contained in:
Looly
2020-10-29 16:19:54 +08:00
parent 19eba6086f
commit 282e1e9090
8 changed files with 39 additions and 24 deletions

View File

@@ -108,11 +108,7 @@ public enum Month {
* @return 此月份最后一天的值
*/
public int getLastDay(boolean isLeapYear) {
int lastDay = DAYS_OF_MONTH[value];
if (isLeapYear && Calendar.FEBRUARY == value){
lastDay += 1;
}
return lastDay;
return getLastDay(this.value, isLeapYear);
}
/**
@@ -166,4 +162,20 @@ public enum Month {
return null;
}
}
/**
* 获得指定月的最后一天
* @param month 月份
* @param isLeapYear 是否为闰年,闰年只对二月有影响
* @return 最后一天可能为28,29,30,31
* @since 5.4.7
*/
public static int getLastDay(int month, boolean isLeapYear){
int lastDay = DAYS_OF_MONTH[month];
if (isLeapYear && Calendar.FEBRUARY == month){
// 二月
lastDay += 1;
}
return lastDay;
}
}