|
|
@@ -28,7 +28,7 @@ public class EquipmentDateUtils extends org.apache.commons.lang3.time.DateUtils
|
|
28
|
28
|
|
|
29
|
29
|
/**
|
|
30
|
30
|
* 判断输入日期是否晚于当前日期,且在两周(14天)以内
|
|
31
|
|
- * 逻辑:输入日期 > 今天 且 输入日期 <= 今天+14天
|
|
|
31
|
+ * 逻辑:输入日期 >= 今天 且 输入日期 <= 今天+14天
|
|
32
|
32
|
*/
|
|
33
|
33
|
public static boolean isWithinTwoWeeks(Date inputDate) {
|
|
34
|
34
|
if (inputDate == null) return false;
|
|
|
@@ -39,7 +39,7 @@ public class EquipmentDateUtils extends org.apache.commons.lang3.time.DateUtils
|
|
39
|
39
|
|
|
40
|
40
|
// isAfter 不包含等于,所以如果今天不算"晚于",用 isAfter
|
|
41
|
41
|
// 如果包含今天之后的第一天,逻辑如下:
|
|
42
|
|
- boolean isAfterToday = inputLocalDate.isAfter(today);
|
|
|
42
|
+ boolean isAfterToday = !inputLocalDate.isBefore(today);
|
|
43
|
43
|
boolean isWithinRange = !inputLocalDate.isAfter(twoWeeksLater); // 小于等于两周后
|
|
44
|
44
|
|
|
45
|
45
|
return isAfterToday && isWithinRange;
|
|
|
@@ -47,7 +47,7 @@ public class EquipmentDateUtils extends org.apache.commons.lang3.time.DateUtils
|
|
47
|
47
|
|
|
48
|
48
|
/**
|
|
49
|
49
|
* 判断输入日期是否晚于当前日期,且在一个月(30天)以内
|
|
50
|
|
- * 逻辑:输入日期 > 今天 且 输入日期 <= 今天+30天
|
|
|
50
|
+ * 逻辑:输入日期 >= 今天 且 输入日期 <= 今天+30天
|
|
51
|
51
|
*/
|
|
52
|
52
|
public static boolean isWithinOneMonth(Date inputDate) {
|
|
53
|
53
|
if (inputDate == null) return false;
|
|
|
@@ -56,7 +56,7 @@ public class EquipmentDateUtils extends org.apache.commons.lang3.time.DateUtils
|
|
56
|
56
|
LocalDate today = LocalDate.now(ZONE_ID);
|
|
57
|
57
|
LocalDate oneMonthLater = today.plusDays(30); // 或者 plusMonths(1),视业务需求定
|
|
58
|
58
|
|
|
59
|
|
- boolean isAfterToday = inputLocalDate.isAfter(today);
|
|
|
59
|
+ boolean isAfterToday = !inputLocalDate.isBefore(today);
|
|
60
|
60
|
boolean isWithinRange = !inputLocalDate.isAfter(oneMonthLater);
|
|
61
|
61
|
|
|
62
|
62
|
return isAfterToday && isWithinRange;
|