Package hudson.scheduler
Class CronTab
- java.lang.Object
-
- hudson.scheduler.CronTab
-
public final class CronTab extends Object
Table for driving scheduled tasks.- Author:
- Kohsuke Kawaguchi
-
-
Constructor Summary
Constructors Constructor Description CronTab(String format)
CronTab(String format, int line)
Deprecated.as of 1.448 UseCronTab(String, int, Hash)
CronTab(String format, int line, Hash hash)
CronTab(String format, int line, Hash hash, String timezone)
CronTab(String format, Hash hash)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Calendar
ceil(long t)
Computes the nearest future timestamp that matches this cron tab.Calendar
ceil(Calendar cal)
Seeceil(long)
.String
checkSanity()
Checks if this crontab entry looks reasonable, and if not, return an warning message.Calendar
floor(long t)
Computes the nearest past timestamp that matched this cron tab.Calendar
floor(Calendar cal)
Seefloor(long)
This method modifies the given calendar and returns the same object.TimeZone
getTimeZone()
Returns the configured time zone, or null if none is configuredstatic String
hashify(String spec)
Checks a prospective crontab specification to see if it could benefit from balanced hashes.String
toString()
-
-
-
Constructor Detail
-
CronTab
public CronTab(String format) throws antlr.ANTLRException
- Throws:
antlr.ANTLRException
-
CronTab
public CronTab(String format, Hash hash) throws antlr.ANTLRException
- Throws:
antlr.ANTLRException
-
CronTab
@Deprecated public CronTab(String format, int line) throws antlr.ANTLRException
Deprecated.as of 1.448 UseCronTab(String, int, Hash)
- Throws:
antlr.ANTLRException
-
CronTab
public CronTab(String format, int line, Hash hash) throws antlr.ANTLRException
- Parameters:
hash
- Used to spread out token like "@daily". Null to preserve the legacy behaviour of not spreading it out at all.- Throws:
antlr.ANTLRException
-
-
Method Detail
-
ceil
public Calendar ceil(long t)
Computes the nearest future timestamp that matches this cron tab.More precisely, given the time 't', computes another smallest time x such that:
- x ≥ t (inclusive)
- x matches this crontab
Note that if t already matches this cron, it's returned as is.
-
ceil
public Calendar ceil(Calendar cal)
Seeceil(long)
. This method modifies the given calendar and returns the same object.- Throws:
RareOrImpossibleDateException
- if the date isn't hit in the 2 years after it indicates an impossible (e.g. Jun 31) date, or at least a date too rare to be useful. This addresses JENKINS-41864 and was added in 2.49
-
floor
public Calendar floor(long t)
Computes the nearest past timestamp that matched this cron tab.More precisely, given the time 't', computes another smallest time x such that:
- x <= t (inclusive)
- x matches this crontab
Note that if t already matches this cron, it's returned as is.
-
floor
public Calendar floor(Calendar cal)
Seefloor(long)
This method modifies the given calendar and returns the same object.- Throws:
RareOrImpossibleDateException
- if the date isn't hit in the 2 years before it indicates an impossible (e.g. Jun 31) date, or at least a date too rare to be useful. This addresses JENKINS-41864 and was added in 2.49
-
checkSanity
@CheckForNull public String checkSanity()
Checks if this crontab entry looks reasonable, and if not, return an warning message.The point of this method is to catch syntactically correct but semantically suspicious combinations, like "* 0 * * *"
-
hashify
@CheckForNull public static String hashify(String spec)
Checks a prospective crontab specification to see if it could benefit from balanced hashes.- Parameters:
spec
- a (legal) spec- Returns:
- a similar spec that uses a hash, if such a transformation is necessary; null if it is OK as is
- Since:
- 1.510
-
getTimeZone
@CheckForNull public TimeZone getTimeZone()
Returns the configured time zone, or null if none is configured- Returns:
- the configured time zone, or null if none is configured
- Since:
- 2.54
-
-