This commit is contained in:
Looly 2020-10-31 10:30:46 +08:00
parent 4f37753b91
commit 6674dcbde7
2 changed files with 11 additions and 12 deletions

View File

@ -165,7 +165,7 @@ public enum Month {
/** /**
* 获得指定月的最后一天 * 获得指定月的最后一天
* @param month 月份 * @param month 月份从0开始
* @param isLeapYear 是否为闰年闰年只对二月有影响 * @param isLeapYear 是否为闰年闰年只对二月有影响
* @return 最后一天可能为28,29,30,31 * @return 最后一天可能为28,29,30,31
* @since 5.4.7 * @since 5.4.7

View File

@ -7,17 +7,16 @@ import java.util.List;
/** /**
* 每月第几天匹配<br> * 每月第几天匹配<br>
* 考虑每月的天数不同且存在闰年情况日匹配单独使用 * 考虑每月的天数不同且存在闰年情况日匹配单独使用
*
* @author Looly
* *
* @author Looly
*/ */
public class DayOfMonthValueMatcher extends BoolArrayValueMatcher { public class DayOfMonthValueMatcher extends BoolArrayValueMatcher {
private static final int[] LAST_DAYS = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; private static final int[] LAST_DAYS = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
/** /**
* 构造 * 构造
* *
* @param intValueList 匹配的日值 * @param intValueList 匹配的日值
*/ */
public DayOfMonthValueMatcher(List<Integer> intValueList) { public DayOfMonthValueMatcher(List<Integer> intValueList) {
@ -26,9 +25,9 @@ public class DayOfMonthValueMatcher extends BoolArrayValueMatcher {
/** /**
* 给定的日期是否匹配当前匹配器 * 给定的日期是否匹配当前匹配器
* *
* @param value 被检查的值此处为日 * @param value 被检查的值此处为日
* @param month 实际的月份 * @param month 实际的月份从1开始
* @param isLeapYear 是否闰年 * @param isLeapYear 是否闰年
* @return 是否匹配 * @return 是否匹配
*/ */
@ -44,13 +43,13 @@ public class DayOfMonthValueMatcher extends BoolArrayValueMatcher {
* 1闰年2月匹配是否为29 * 1闰年2月匹配是否为29
* 2其它月份是否匹配最后一天的日期可能为30或者31 * 2其它月份是否匹配最后一天的日期可能为30或者31
* </pre> * </pre>
* *
* @param value 被检查的值 * @param value 被检查的值
* @param month 月份 * @param month 月份从1开始
* @param isLeapYear 是否闰年 * @param isLeapYear 是否闰年
* @return 是否为本月最后一天 * @return 是否为本月最后一天
*/ */
private static boolean isLastDayOfMonth(int value, int month, boolean isLeapYear) { private static boolean isLastDayOfMonth(int value, int month, boolean isLeapYear) {
return value == Month.getLastDay(month, isLeapYear); return value == Month.getLastDay(month - 1, isLeapYear);
} }
} }