You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: org.springframework.context/src/main/java/org/springframework/scheduling/support/CronSequenceGenerator.java
+43-13Lines changed: 43 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -66,7 +66,6 @@ class CronSequenceGenerator {
66
66
67
67
privatefinalStringexpression;
68
68
69
-
70
69
/**
71
70
* Construct a {@link CronSequenceGenerator} from the pattern provided.
72
71
* @param expression a space-separated list of time fields
@@ -77,7 +76,6 @@ public CronSequenceGenerator(String expression) {
77
76
parse(expression);
78
77
}
79
78
80
-
81
79
/**
82
80
* Get the next {@link Date} in the sequence matching the Cron pattern and
83
81
* after the value provided. The return value will have a whole number of
@@ -86,17 +84,45 @@ public CronSequenceGenerator(String expression) {
86
84
* @return the next value matching the pattern
87
85
*/
88
86
publicDatenext(Datedate) {
87
+
88
+
/*
89
+
The plan:
90
+
91
+
1 Round up to the next whole second
92
+
93
+
2 If seconds match move on, otherwise find the next match:
94
+
2.1 If next match is in the next minute then roll forwards
95
+
96
+
3 If minute matches move on, otherwise find the next match
97
+
3.1 If next match is in the next hour then roll forwards
98
+
3.2 Reset the seconds and go to 2
99
+
100
+
4 If hour matches move on, otherwise find the next match
101
+
4.1 If next match is in the next day then roll forwards,
102
+
4.2 Reset the minutes and seconds and go to 2
103
+
104
+
...
105
+
106
+
*/
107
+
89
108
Calendarcalendar = newGregorianCalendar();
90
109
calendar.setTime(date);
91
110
92
111
// Truncate to the next whole second
93
112
calendar.add(Calendar.SECOND, 1);
94
113
calendar.set(Calendar.MILLISECOND, 0);
95
114
115
+
doNext(calendar);
116
+
117
+
returncalendar.getTime();
118
+
}
119
+
120
+
privatevoiddoNext(Calendarcalendar) {
96
121
List<Integer> resets = newArrayList<Integer>();
97
122
98
123
intsecond = calendar.get(Calendar.SECOND);
99
-
intupdateSecond = findNext(this.seconds, second, 60, calendar, Calendar.SECOND, Collections.<Integer> emptyList());
0 commit comments