Class CronSchedule
When a cron job fires: six sets of allowed values, held as bit masks.
The build parses every literal @Scheduled(cron = ...) expression
and writes the masks into the entry point it generates, so a server never
parses one and a malformed one never reaches a server. parse(String, String) exists
for the other case -- an expression read from configuration, which only exists
at start-up -- and implements the same grammar; the plugin's tests hold the two
to agreeing on every expression they know.
The grammar is Spring's six fields: second, minute, hour, day of month,
month, day of week. Each is * (or ? for the two day fields), a
value, a range a-b, a step *``/n or a-b/n or
a/n, or a comma-separated list of those. Months and days take their
three-letter English names; Sunday is 0 or 7. L as the day of month is
the last day of the month. The macros @yearly, @annually,
@monthly, @weekly, @daily, @midnight and
@hourly stand for their usual expressions.
When both day fields are restricted a day must match BOTH, which is Spring's rule rather than Unix cron's either-or.
-
Constructor Summary
ConstructorsConstructorDescriptionCronSchedule(long seconds, long minutes, long hours, long daysOfMonth, long months, long daysOfWeek, boolean lastDayOfMonth, String zone, String expression) The masks the build computed. -
Method Summary
Modifier and TypeMethodDescriptionThe expression this was made from, for a listing.getZone()The zone it is read in.static StringThe expansion of a macro, or null.longnext(long afterMillis) The first time strictly afterafterMillisthis fires, as epoch milliseconds, or -1 if it never does (the 30th of February).static CronScheduleParses an expression at run time, for one that came from configuration.static intparseFixedOffset(String zone) Milliseconds east of UTC for "UTC", "Z", "GMT" or "+hh:mm"; MIN_VALUE otherwise.toString()Returns a string representation of the object.
-
Constructor Details
-
CronSchedule
public CronSchedule(long seconds, long minutes, long hours, long daysOfMonth, long months, long daysOfWeek, boolean lastDayOfMonth, String zone, String expression) The masks the build computed. Called by generated code.
Parameters
zone: @param zone a zone ID, a fixed offset such as+02:00, or null or empty for UTC
-
-
Method Details
-
getExpression
The expression this was made from, for a listing. -
getZone
The zone it is read in. -
parse
Parses an expression at run time, for one that came from configuration.
Throws
IllegalArgumentException: naming what is wrong
-
macro
-
parseFixedOffset
Milliseconds east of UTC for "UTC", "Z", "GMT" or "+hh:mm"; MIN_VALUE otherwise. -
next
public long next(long afterMillis) The first time strictly afterafterMillisthis fires, as epoch milliseconds, or -1 if it never does (the 30th of February). -
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-