Package rife.scheduler
Class Frequency
java.lang.Object
rife.scheduler.Frequency
Defines the frequency at which a task should execute.
This is inspired by the standard unix crontab frequency specification.
A number of frequently used frequencies are available as static constants, a DSL is provided to build the most features of frequency specification, or a textual specification can be provided that will be parsed.
- Since:
- 1.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Frequency
Schedule every day at midnight.static final Frequency
Schedule every friday at midnight.static final Frequency
Schedule every hour on the hour.static final Frequency
Schedule every minute.static final Frequency
Schedule every monday at midnight.static final Frequency
Schedule every month on the first day at midnight.static final Frequency
Schedule every quarter on the first day at midnight.static final Frequency
Schedule every saturday at midnight.static final Frequency
Schedule every sunday at midnight.static final Frequency
Schedule every thursday at midnight.static final Frequency
Schedule every tuesday at midnight.static final Frequency
Schedule every wednesday at midnight.static final Frequency
Schedule every year on the first day at midnight. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionat
(int hour, int minute) Schedule at a specific time.atHour
(int hour) Schedule at a specific hour of the day.atHours
(int... hours) Schedule at specific hours of the day.atMinute
(int minute) Schedule at a specific minute of the hour.atMinutes
(int... minutes) Schedule at specific minutes of the hour.Schedule every day of the week in a range.Schedule every month of the year.duringDates
(int first, int last) Schedule every day of the month in a range, 1-based.duringHours
(int first, int last) Schedule every hour of the day in a range.duringMinutes
(int first, int last) Schedule every minute of the hour in a range.boolean
Schedule every day of the month.everyDate
(int step) Schedule every n-th day of the monthSchedule every hour of the day.everyHour
(int step) Schedule every n-th hour of the daySchedule every minute of the hour.everyMinute
(int step) Schedule every n-th minute of the hourSchedule every month of the year.everyMonth
(int step) Schedule every n-th month of the yearSchedule every day of the week.everyWeekday
(int step) Schedule every n-th day of the weekint
hashCode()
Schedule in a specific month of the year.Schedule in specific months of the year.Schedule on a specific day of the week.Schedule on a specific days of the week.Schedule on a specific day.onDate
(int date) Schedule on a specific day of the month, 1-based.onDates
(int... dates) Schedule on specific days of the month, 1-based.void
reset()
Reset the frequency to be scheduler every minute.toString()
-
Field Details
-
MINUTELY
Schedule every minute.- Since:
- 1.0
-
HOURLY
Schedule every hour on the hour.- Since:
- 1.0
-
DAILY
Schedule every day at midnight.- Since:
- 1.0
-
MONDAYS
Schedule every monday at midnight.- Since:
- 1.0
-
TUESDAYS
Schedule every tuesday at midnight.- Since:
- 1.0
-
WEDNESDAYS
Schedule every wednesday at midnight.- Since:
- 1.0
-
THURSDAYS
Schedule every thursday at midnight.- Since:
- 1.0
-
FRIDAYS
Schedule every friday at midnight.- Since:
- 1.0
-
SATURDAYS
Schedule every saturday at midnight.- Since:
- 1.0
-
SUNDAYS
Schedule every sunday at midnight.- Since:
- 1.0
-
MONTHLY
Schedule every month on the first day at midnight.- Since:
- 1.0
-
QUARTERLY
Schedule every quarter on the first day at midnight.- Since:
- 1.0
-
YEARLY
Schedule every year on the first day at midnight.- Since:
- 1.0
-
-
Constructor Details
-
Frequency
public Frequency()Creates a new frequency instance that will schedule every minute.- Since:
- 1.0
-
Frequency
Creates a new frequency instance from the provided crontab specification.- Parameters:
specification
- the specification string that will be parsed- Throws:
FrequencyException
- when an error occurs during the parsing- Since:
- 1.0
-
-
Method Details
-
at
Schedule at a specific time.- Parameters:
hour
- the hour to schedule, 24-hours, 0-basedminute
- the time to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
on
Schedule on a specific day.- Parameters:
month
- the month to scheduledate
- the day of the month to schedule, 1-based- Returns:
- this frequency instance
- Since:
- 1.0
-
everyMinute
Schedule every minute of the hour.- Returns:
- this frequency instance
- Since:
- 1.0
-
everyMinute
Schedule every n-th minute of the hourFor instance a step of 10 will schedule on minutes 0, 10, 20, 30, 40, and 50.
- Parameters:
step
- the step to use to skip over the minutes- Returns:
- this frequency instance
- Since:
- 1.0
-
atMinute
Schedule at a specific minute of the hour.- Parameters:
minute
- to minute in the hour to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
atMinutes
Schedule at specific minutes of the hour.- Parameters:
minutes
- the minutes in the hour to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
duringMinutes
Schedule every minute of the hour in a range.- Parameters:
first
- the first minute in the rangelast
- the last minute in the range, included- Returns:
- this frequency instance
- Since:
- 1.0
-
everyHour
Schedule every hour of the day.- Returns:
- this frequency instance
- Since:
- 1.0
-
everyHour
Schedule every n-th hour of the dayFor instance a step of 6 will schedule on hours 0, 6, 12, 18, and 24.
- Parameters:
step
- the step to use to skip over the hours- Returns:
- this frequency instance
- Since:
- 1.0
-
atHour
Schedule at a specific hour of the day.- Parameters:
hour
- to hour in the day to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
atHours
Schedule at specific hours of the day.- Parameters:
hours
- the hours in the day to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
duringHours
Schedule every hour of the day in a range.- Parameters:
first
- the first hour in the rangelast
- the last hour in the range, included- Returns:
- this frequency instance
- Since:
- 1.0
-
everyDate
Schedule every day of the month.- Returns:
- this frequency instance
- Since:
- 1.0
-
everyDate
Schedule every n-th day of the monthFor instance a step of 12 will schedule on day 1, 13, and 25.
- Parameters:
step
- the step to use to skip over the days- Returns:
- this frequency instance
- Since:
- 1.0
-
onDate
Schedule on a specific day of the month, 1-based.- Parameters:
date
- to day in the month to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
onDates
Schedule on specific days of the month, 1-based.- Parameters:
dates
- the days in the month to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
duringDates
Schedule every day of the month in a range, 1-based.- Parameters:
first
- the first day in the rangelast
- the last day in the range, included- Returns:
- this frequency instance
- Since:
- 1.0
-
everyMonth
Schedule every month of the year.- Returns:
- this frequency instance
- Since:
- 1.0
-
everyMonth
Schedule every n-th month of the yearFor instance a step of 3 will schedule on months 1, 4, 7, and 10.
- Parameters:
step
- the step to use to skip over the months- Returns:
- this frequency instance
- Since:
- 1.0
-
in
Schedule in a specific month of the year.- Parameters:
month
- to month of the year to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
in
Schedule in specific months of the year.- Parameters:
months
- to months of the year to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
between
Schedule every month of the year.- Parameters:
first
- the first month in the rangelast
- the last month in the range, included- Returns:
- this frequency instance
- Since:
- 1.0
-
everyWeekday
Schedule every day of the week.- Returns:
- this frequency instance
- Since:
- 1.0
-
everyWeekday
Schedule every n-th day of the weekFor instance a step of 2 will schedule on day 1, 3, 5 and 7.
- Parameters:
step
- the step to use to skip over the days- Returns:
- this frequency instance
- Since:
- 1.0
-
on
Schedule on a specific day of the week.- Parameters:
weekday
- to day of the week to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
on
Schedule on a specific days of the week.- Parameters:
weekdays
- to days of the week to schedule- Returns:
- this frequency instance
- Since:
- 1.0
-
between
Schedule every day of the week in a range.- Parameters:
first
- the first day in the rangelast
- the last day in the range, included- Returns:
- this frequency instance
- Since:
- 1.0
-
toString
-
reset
public void reset()Reset the frequency to be scheduler every minute.- Since:
- 1.0
-
equals
-
hashCode
public int hashCode()
-