[Feat](job)scheduled job allows the time to be set in the past (#36732) (#37573)

## Proposed changes

In some cases, users want to set the start time to a time in the past.

**For periodic scheduling tasks only, the start time of a one-time task
must be set to the future or present time**
**If the start time is the past time, then the next execution time
should be the start time + time interval.**

(cherry picked from commit fa6061070f6d4063b1966e99fc285e4e6b9c3750)



#36732
This commit is contained in:
Calvin Kirs
2024-07-18 19:15:10 +08:00
committed by GitHub
parent bd00f56b10
commit 4f03bde1e8
4 changed files with 20 additions and 7 deletions

View File

@ -96,7 +96,7 @@ public class JobExecutionConfiguration {
return;
}
if (timerDefinition.getStartTimeMs() < System.currentTimeMillis()) {
throw new IllegalArgumentException("startTimeMs cannot be less than current time");
throw new IllegalArgumentException("startTimeMs must be greater than current time");
}
}

View File

@ -39,9 +39,6 @@ public class TimerDefinition {
public void checkParams(boolean immediate) {
if (null != startTimeMs && startTimeMs < System.currentTimeMillis()) {
throw new IllegalArgumentException("startTimeMs must be greater than current time");
}
if (null != startTimeMs && immediate) {
throw new IllegalArgumentException("startTimeMs must be null when immediate is true");
}
@ -52,7 +49,7 @@ public class TimerDefinition {
startTimeMs = System.currentTimeMillis() + intervalUnit.getIntervalMs(interval);
}
if (null != endTimeMs && endTimeMs < startTimeMs) {
throw new IllegalArgumentException("end time cannot be less than start time");
throw new IllegalArgumentException("endTimeMs must be greater than the start time");
}
if (null != intervalUnit) {