@@ -148,7 +148,13 @@ public static Date getNextRunTime(IntervalType type, String schedule, String tim
148148 scheduleTime .set (Calendar .MINUTE , minutes );
149149 scheduleTime .set (Calendar .SECOND , 0 );
150150 scheduleTime .set (Calendar .MILLISECOND , 0 );
151- execDate = scheduleTime .getTime ();
151+ try {
152+ execDate = scheduleTime .getTime ();
153+ } catch (IllegalArgumentException ex ) {
154+ scheduleTime .setLenient (true );
155+ execDate = scheduleTime .getTime ();
156+ scheduleTime .setLenient (false );
157+ }
152158 // XXX: !execDate.after(startDate) is strictly for testing.
153159 // During testing we use a test clock which runs much faster than the real clock
154160 // So startDate and execDate will always be ahead in the future
@@ -168,7 +174,13 @@ public static Date getNextRunTime(IntervalType type, String schedule, String tim
168174 scheduleTime .set (Calendar .MINUTE , minutes );
169175 scheduleTime .set (Calendar .SECOND , 0 );
170176 scheduleTime .set (Calendar .MILLISECOND , 0 );
171- execDate = scheduleTime .getTime ();
177+ try {
178+ execDate = scheduleTime .getTime ();
179+ } catch (IllegalArgumentException ex ) {
180+ scheduleTime .setLenient (true );
181+ execDate = scheduleTime .getTime ();
182+ scheduleTime .setLenient (false );
183+ }
172184 // XXX: !execDate.after(startDate) is strictly for testing.
173185 // During testing we use a test clock which runs much faster than the real clock
174186 // So startDate and execDate will always be ahead in the future
@@ -189,7 +201,13 @@ public static Date getNextRunTime(IntervalType type, String schedule, String tim
189201 scheduleTime .set (Calendar .MINUTE , minutes );
190202 scheduleTime .set (Calendar .SECOND , 0 );
191203 scheduleTime .set (Calendar .MILLISECOND , 0 );
192- execDate = scheduleTime .getTime ();
204+ try {
205+ execDate = scheduleTime .getTime ();
206+ } catch (IllegalArgumentException ex ) {
207+ scheduleTime .setLenient (true );
208+ execDate = scheduleTime .getTime ();
209+ scheduleTime .setLenient (false );
210+ }
193211 // XXX: !execDate.after(startDate) is strictly for testing.
194212 // During testing we use a test clock which runs much faster than the real clock
195213 // So startDate and execDate will always be ahead in the future
@@ -213,7 +231,13 @@ public static Date getNextRunTime(IntervalType type, String schedule, String tim
213231 scheduleTime .set (Calendar .MINUTE , minutes );
214232 scheduleTime .set (Calendar .SECOND , 0 );
215233 scheduleTime .set (Calendar .MILLISECOND , 0 );
216- execDate = scheduleTime .getTime ();
234+ try {
235+ execDate = scheduleTime .getTime ();
236+ } catch (IllegalArgumentException ex ) {
237+ scheduleTime .setLenient (true );
238+ execDate = scheduleTime .getTime ();
239+ scheduleTime .setLenient (false );
240+ }
217241 // XXX: !execDate.after(startDate) is strictly for testing.
218242 // During testing we use a test clock which runs much faster than the real clock
219243 // So startDate and execDate will always be ahead in the future
@@ -226,7 +250,14 @@ public static Date getNextRunTime(IntervalType type, String schedule, String tim
226250 throw new CloudRuntimeException ("Incorrect interval: " +type .toString ());
227251 }
228252
229- return scheduleTime .getTime ();
253+ try {
254+ return scheduleTime .getTime ();
255+ } catch (IllegalArgumentException ex ) {
256+ scheduleTime .setLenient (true );
257+ Date nextScheduledDate = scheduleTime .getTime ();
258+ scheduleTime .setLenient (false );
259+ return nextScheduledDate ;
260+ }
230261 }
231262
232263 public static long getTimeDifference (Date date1 , Date date2 ){
0 commit comments