ソースを参照

fix Validator

Looly 6 年 前
コミット
46fd3912d4

+ 1 - 0
CHANGELOG.md

@@ -12,6 +12,7 @@
 * 【core】        改进ArrayUtil.toString,提高性能
 * 【core】        改进ArrayUtil.toString,提高性能
 * 【system】      增加SystemPropsKeys(issue#550@Github)
 * 【system】      增加SystemPropsKeys(issue#550@Github)
 * 【core】        FileUtil.normalize在win下支持samba路径(issue#549@Github)
 * 【core】        FileUtil.normalize在win下支持samba路径(issue#549@Github)
+* 【core】        修复Validator注释错误(pr#70@Gitee)
 
 
 ### Bug修复
 ### Bug修复
 * 【core】        修复DateUtil.offset导致的时区错误问题(issue#I1294O@Gitee)
 * 【core】        修复DateUtil.offset导致的时区错误问题(issue#I1294O@Gitee)

+ 4 - 6
hutool-core/src/main/java/cn/hutool/core/lang/Validator.java

@@ -174,7 +174,6 @@ public class Validator {
 	 * 
 	 * 
 	 * @param value 值
 	 * @param value 值
 	 * @return 是否为空
 	 * @return 是否为空
-	 * @return 是否为空
 	 */
 	 */
 	public static boolean isEmpty(Object value) {
 	public static boolean isEmpty(Object value) {
 		return (null == value || (value instanceof String && StrUtil.isEmpty((String) value)));
 		return (null == value || (value instanceof String && StrUtil.isEmpty((String) value)));
@@ -186,7 +185,6 @@ public class Validator {
 	 * 
 	 * 
 	 * @param value 值
 	 * @param value 值
 	 * @return 是否为空
 	 * @return 是否为空
-	 * @return 是否为空
 	 */
 	 */
 	public static boolean isNotEmpty(Object value) {
 	public static boolean isNotEmpty(Object value) {
 		return false == isEmpty(value);
 		return false == isEmpty(value);
@@ -733,13 +731,13 @@ public class Validator {
 		if (day < 1 || day > 31) {
 		if (day < 1 || day > 31) {
 			return false;
 			return false;
 		}
 		}
-		if ((month == 4 || month == 6 || month == 9 || month == 11) && day == 31) {
+		// 检查几个特殊月的最大天数
+		if (day == 31 && (month == 4 || month == 6 || month == 9 || month == 11)) {
 			return false;
 			return false;
 		}
 		}
 		if (month == 2) {
 		if (month == 2) {
-			if (day > 29 || (day == 29 && false == DateUtil.isLeapYear(year))) {
-				return false;
-			}
+			// 在2月,非闰年最大28,闰年最大29
+			return day < 29 || (day == 29 && DateUtil.isLeapYear(year));
 		}
 		}
 		return true;
 		return true;
 	}
 	}