@@ -42,7 +42,7 @@ private DateUtils() {}
42
42
* @since 1.1.3
43
43
*/
44
44
public static Date getStartOfThisMonth () {
45
- return checkThisMonth (startOfThisMonth , startOfThisMonthCopier );
45
+ return checkThisMonth (true , startOfThisMonthCopier );
46
46
}
47
47
48
48
/**
@@ -53,7 +53,7 @@ public static Date getStartOfThisMonth() {
53
53
* @since 1.1.3
54
54
*/
55
55
public static Date getEndOfThisMonth () {
56
- return checkThisMonth (endOfThisMonth , endOfThisMonthCopier );
56
+ return checkThisMonth (false , endOfThisMonthCopier );
57
57
}
58
58
59
59
/**
@@ -64,7 +64,7 @@ public static Date getEndOfThisMonth() {
64
64
* @since 1.0.9
65
65
*/
66
66
public static Date getStartOfToday () {
67
- return checkToday (startOfToday , startOfTodayCopier );
67
+ return checkToday (true , startOfTodayCopier );
68
68
}
69
69
70
70
/**
@@ -75,35 +75,35 @@ public static Date getStartOfToday() {
75
75
* @since 1.0.9
76
76
*/
77
77
public static Date getEndOfToday () {
78
- return checkToday (endOfToday , endOfTodayCopier );
78
+ return checkToday (false , endOfTodayCopier );
79
79
}
80
80
81
81
/**
82
82
* 使用副本来防止原引用被篡改
83
83
*/
84
- private static Date checkThisMonth (long origin , Date copier ) {
84
+ private static Date checkThisMonth (boolean isStart , Date copier ) {
85
85
long curr = System .currentTimeMillis ();
86
86
if (curr > endOfThisMonth ) {
87
87
// 如果当前的时间戳超过了endOfThisMonth的时间戳,说明ThisMonth的时间戳已经过期,需重新设置
88
88
Date date = new Date ();
89
89
startOfThisMonth = DateUtil .beginOfMonth (date ).getTime ();
90
90
endOfThisMonth = DateUtil .endOfMonth (date ).getTime ();
91
91
}
92
- return check (origin , copier );
92
+ return check (isStart ? startOfThisMonth : endOfThisMonth , copier );
93
93
}
94
94
95
95
/**
96
96
* 使用副本来防止原引用被篡改
97
97
*/
98
- private static Date checkToday (long origin , Date copier ) {
98
+ private static Date checkToday (boolean isStart , Date copier ) {
99
99
long curr = System .currentTimeMillis ();
100
100
if (curr > endOfToday ) {
101
101
// 如果当前的时间戳超过了endOfToday的时间戳,说明Today的时间戳已经过期,需重新设置
102
102
Date date = new Date ();
103
103
startOfToday = DateUtil .beginOfDay (date ).getTime ();
104
104
endOfToday = DateUtil .endOfDay (date ).getTime ();
105
105
}
106
- return check (origin , copier );
106
+ return check (isStart ? startOfToday : endOfToday , copier );
107
107
}
108
108
109
109
private static Date check (long origin , Date copier ) {
0 commit comments