|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.quartz.helpers.TriggerUtils
Convenience and utility methods for simplifying the construction and
configuration of
.
Trigger
s
Please submit suggestions for additional convenience methods to either the Quartz user forum or the developer's mail list at source forge.
CronTrigger
,
SimpleTrigger
Field Summary | |
static int |
FRIDAY
|
static int |
LAST_DAY_OF_MONTH
|
static long |
MILLISECONDS_IN_DAY
|
static long |
MILLISECONDS_IN_HOUR
|
static long |
MILLISECONDS_IN_MINUTE
|
static int |
MONDAY
|
static int |
SATURDAY
|
static long |
SECONDS_IN_DAY
|
static int |
SUNDAY
|
static int |
THURSDAY
|
static int |
TUESDAY
|
static int |
WEDNESDAY
|
Constructor Summary | |
TriggerUtils()
|
Method Summary | |
static java.util.List |
computeFireTimes(Trigger trigg,
Calendar cal,
int numTimes)
Returns a list of Dates that are the next fire times of a Trigger . |
static java.util.List |
computeFireTimesBetween(Trigger trigg,
Calendar cal,
java.util.Date from,
java.util.Date to)
Returns a list of Dates that are the next fire times of a Trigger
that fall within the given date range. |
static java.util.Date |
getDateOf(int second,
int minute,
int hour)
Get a Date object that represents the given time, on
today's date. |
static java.util.Date |
getDateOf(int second,
int minute,
int hour,
int dayOfMonth,
int month)
Get a Date object that represents the given time, on the
given date. |
static java.util.Date |
getDateOf(int second,
int minute,
int hour,
int dayOfMonth,
int month,
int year)
Get a Date object that represents the given time, on the
given date. |
static java.util.Date |
getEvenHourDate(java.util.Date date)
Returns a date that is rounded to the next even hour above the given date. |
static java.util.Date |
getEvenHourDateBefore(java.util.Date date)
Returns a date that is rounded to the previous even hour below the given date. |
static java.util.Date |
getEvenMinuteDate(java.util.Date date)
Returns a date that is rounded to the next even hour above the given date. |
static java.util.Date |
getEvenMinuteDateBefore(java.util.Date date)
Returns a date that is rounded to the previous even hour below the given date. |
static java.util.Date |
getEvenSecondDate(java.util.Date date)
Returns a date that is rounded to the next even second above the given date. |
static java.util.Date |
getEvenSecondDateBefore(java.util.Date date)
Returns a date that is rounded to the previous even second below the given date. |
static java.util.Date |
getNextGivenMinuteDate(java.util.Date date,
int minuteBase)
Returns a date that is rounded to the next even multiple of the given minute. |
static java.util.Date |
getNextGivenSecondDate(java.util.Date date,
int secondBase)
Returns a date that is rounded to the next even multiple of the given minute. |
static Trigger |
makeDailyTrigger(int hour,
int minute)
Make a trigger that will fire every day at the given time. |
static Trigger |
makeHourlyTrigger()
Make a trigger that will fire every hour, indefinitely. |
static Trigger |
makeHourlyTrigger(int intervalInHours)
Make a trigger that will fire every N hours, indefinitely. |
static Trigger |
makeHourlyTrigger(int intervalInHours,
int repeatCount)
Make a trigger that will fire every N hours, with the given number of repeats. |
static Trigger |
makeMinutelyTrigger()
Make a trigger that will fire every minute, indefinitely. |
static Trigger |
makeMinutelyTrigger(int intervalInMinutes)
Make a trigger that will fire every N minutes, indefinitely. |
static Trigger |
makeMinutelyTrigger(int intervalInMinutes,
int repeatCount)
Make a trigger that will fire every N minutes, with the given number of repeats. |
static Trigger |
makeMonthlyTrigger(int dayOfMonth,
int hour,
int minute)
Make a trigger that will fire every day at the given time. |
static Trigger |
makeSecondlyTrigger()
Make a trigger that will fire every second, indefinitely. |
static Trigger |
makeSecondlyTrigger(int intervalInSeconds)
Make a trigger that will fire every N seconds, indefinitely. |
static Trigger |
makeSecondlyTrigger(int intervalInSeconds,
int repeatCount)
Make a trigger that will fire every N seconds, with the given number of repeats. |
static Trigger |
makeWeeklyTrigger(int dayOfWeek,
int hour,
int minute)
Make a trigger that will fire every day at the given time. |
static void |
setTriggerIdentity(Trigger trig,
java.lang.String name)
Set the given Trigger 's name to the given value, and its
group to the default group (Scheduler.DEFAULT_GROUP ). |
static void |
setTriggerIdentity(Trigger trig,
java.lang.String name,
java.lang.String group)
Set the given Trigger 's name to the given value, and its
group to the given group. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int SUNDAY
public static final int MONDAY
public static final int TUESDAY
public static final int WEDNESDAY
public static final int THURSDAY
public static final int FRIDAY
public static final int SATURDAY
public static final int LAST_DAY_OF_MONTH
public static final long MILLISECONDS_IN_MINUTE
public static final long MILLISECONDS_IN_HOUR
public static final long SECONDS_IN_DAY
public static final long MILLISECONDS_IN_DAY
Constructor Detail |
public TriggerUtils()
Method Detail |
public static void setTriggerIdentity(Trigger trig, java.lang.String name)
Set the given Trigger
's name to the given value, and its
group to the default group (Scheduler.DEFAULT_GROUP
).
public static void setTriggerIdentity(Trigger trig, java.lang.String name, java.lang.String group)
Set the given Trigger
's name to the given value, and its
group to the given group.
public static Trigger makeDailyTrigger(int hour, int minute)
Make a trigger that will fire every day at the given time.
The generated trigger will still need to have its name, group, start-time and end-time set.
hour
- the hour (0-23) upon which to fireminute
- the minute (0-59) upon which to firepublic static Trigger makeWeeklyTrigger(int dayOfWeek, int hour, int minute)
Make a trigger that will fire every day at the given time.
The generated trigger will still need to have its name, group, start-time and end-time set.
dayOfWeek
- (1-7) the day of week upon which to firehour
- the hour (0-23) upon which to fireminute
- the minute (0-59) upon which to fireSUNDAY
,
MONDAY
,
TUESDAY
,
WEDNESDAY
,
THURSDAY
,
FRIDAY
,
SATURDAY
public static Trigger makeMonthlyTrigger(int dayOfMonth, int hour, int minute)
Make a trigger that will fire every day at the given time.
The generated trigger will still need to have its name, group, start-time and end-time set.
If the day of the month specified does not occur in a given month, a firing will not occur that month. (i.e. if dayOfMonth is specified as 31, no firing will occur in the months of the year with fewer than 31 days).
dayOfMonth
- (1-31, or -1) the day of week upon which to firehour
- the hour (0-23) upon which to fireminute
- the minute (0-59) upon which to firepublic static Trigger makeSecondlyTrigger()
Make a trigger that will fire every second, indefinitely.
The generated trigger will still need to have its name, group, start-time and end-time set.
public static Trigger makeSecondlyTrigger(int intervalInSeconds)
Make a trigger that will fire every N seconds, indefinitely.
The generated trigger will still need to have its name, group, start-time and end-time set.
intervalInSeconds
- the number of seconds between firingspublic static Trigger makeSecondlyTrigger(int intervalInSeconds, int repeatCount)
Make a trigger that will fire every N seconds, with the given number of repeats.
The generated trigger will still need to have its name, group, start-time and end-time set.
intervalInSeconds
- the number of seconds between firingsrepeatCount
- the number of times to repeat the firingpublic static Trigger makeMinutelyTrigger()
Make a trigger that will fire every minute, indefinitely.
The generated trigger will still need to have its name, group, start-time and end-time set.
public static Trigger makeMinutelyTrigger(int intervalInMinutes)
Make a trigger that will fire every N minutes, indefinitely.
The generated trigger will still need to have its name, group, start-time and end-time set.
intervalInMinutes
- the number of minutes between firingspublic static Trigger makeMinutelyTrigger(int intervalInMinutes, int repeatCount)
Make a trigger that will fire every N minutes, with the given number of repeats.
The generated trigger will still need to have its name, group, start-time and end-time set.
intervalInMinutes
- the number of minutes between firingsrepeatCount
- the number of times to repeat the firingpublic static Trigger makeHourlyTrigger()
Make a trigger that will fire every hour, indefinitely.
The generated trigger will still need to have its name, group, start-time and end-time set.
public static Trigger makeHourlyTrigger(int intervalInHours)
Make a trigger that will fire every N hours, indefinitely.
The generated trigger will still need to have its name, group, start-time and end-time set.
intervalInHours
- the number of hours between firingspublic static Trigger makeHourlyTrigger(int intervalInHours, int repeatCount)
Make a trigger that will fire every N hours, with the given number of repeats.
The generated trigger will still need to have its name, group, start-time and end-time set.
intervalInHours
- the number of hours between firingsrepeatCount
- the number of times to repeat the firingpublic static java.util.Date getEvenHourDate(java.util.Date date)
Returns a date that is rounded to the next even hour above the given date.
For example an input date with a time of 08:13:54 would result in a date with the time of 09:00:00. If the date's time is in the 23rd hour, the date's 'day' will be promoted, and the time will be set to 00:00:00.
date
- the Date to round, if null
the current time will
be usedpublic static java.util.Date getEvenHourDateBefore(java.util.Date date)
Returns a date that is rounded to the previous even hour below the given date.
For example an input date with a time of 08:13:54 would result in a date with the time of 08:00:00.
date
- the Date to round, if null
the current time will
be usedpublic static java.util.Date getEvenMinuteDate(java.util.Date date)
Returns a date that is rounded to the next even hour above the given date.
For example an input date with a time of 08:13:54 would result in a date with the time of 08:14:00. If the date's time is in the 59th minute, then the hour (and possibly the day) will be promoted.
date
- the Date to round, if null
the current time will
be usedpublic static java.util.Date getEvenMinuteDateBefore(java.util.Date date)
Returns a date that is rounded to the previous even hour below the given date.
For example an input date with a time of 08:13:54 would result in a date with the time of 08:13:00.
date
- the Date to round, if null
the current time will
be usedpublic static java.util.Date getEvenSecondDate(java.util.Date date)
Returns a date that is rounded to the next even second above the given date.
date
- the Date to round, if null
the current time will
be usedpublic static java.util.Date getEvenSecondDateBefore(java.util.Date date)
Returns a date that is rounded to the previous even second below the given date.
For example an input date with a time of 08:13:54.341 would result in a date with the time of 08:13:00.000.
date
- the Date to round, if null
the current time will
be usedpublic static java.util.Date getNextGivenMinuteDate(java.util.Date date, int minuteBase)
Returns a date that is rounded to the next even multiple of the given minute.
For example an input date with a time of 08:13:54, and an input minute-base of 5 would result in a date with the time of 08:15:00. The same input date with an input minute-base of 10 would result in a date with the time of 08:20:00. But a date with the time 08:53:31 and an input minute-base of 45 would result in 09:00:00, because the even-hour is the next 'base' for 45-minute intervals.
More examples:
Input Time | Minute-Base | Result Time |
---|---|---|
11:16:41 | 20 | 11:20:00 |
11:36:41 | 20 | 11:40:00 |
11:46:41 | 20 | 12:00:00 |
11:26:41 | 30 | 11:30:00 |
11:36:41 | 30 | 12:00:00 | 11:16:41 | 17 | 11:17:00 | 11:17:41 | 17 | 11:34:00 | 11:52:41 | 17 | 12:00:00 | 11:52:41 | 5 | 11:55:00 | 11:57:41 | 5 | 12:00:00 | 11:17:41 | 0 | 12:00:00 | 11:17:41 | 1 | 11:08:00 |
date
- the Date to round, if null
the current time will
be usedminuteBase
- the base-minute to set the time ongetNextGivenSecondDate(Date, int)
public static java.util.Date getNextGivenSecondDate(java.util.Date date, int secondBase)
Returns a date that is rounded to the next even multiple of the given minute.
The rules for calculating the second are the same as those for
calculating the minute in the method getNextGivenMinuteDate(..)
.
date
- the Date to round, if null
the current time will
be usedsecondBase
- the base-second to set the time ongetNextGivenMinuteDate(Date, int)
public static java.util.Date getDateOf(int second, int minute, int hour)
Get a Date
object that represents the given time, on
today's date.
second
- The value (0-59) to give the seconds field of the dateminute
- The value (0-59) to give the minutes field of the datehour
- The value (0-23) to give the hours field of the datepublic static java.util.Date getDateOf(int second, int minute, int hour, int dayOfMonth, int month)
Get a Date
object that represents the given time, on the
given date.
second
- The value (0-59) to give the seconds field of the dateminute
- The value (0-59) to give the minutes field of the datehour
- The value (0-23) to give the hours field of the datedayOfMonth
- The value (1-31) to give the day of month field of the datemonth
- The value (1-12) to give the month field of the datepublic static java.util.Date getDateOf(int second, int minute, int hour, int dayOfMonth, int month, int year)
Get a Date
object that represents the given time, on the
given date.
second
- The value (0-59) to give the seconds field of the dateminute
- The value (0-59) to give the minutes field of the datehour
- The value (0-23) to give the hours field of the datedayOfMonth
- The value (1-31) to give the day of month field of the datemonth
- The value (1-12) to give the month field of the dateyear
- The value (1970-2099) to give the year field of the datepublic static java.util.List computeFireTimes(Trigger trigg, Calendar cal, int numTimes)
Trigger
.
The input trigger will be cloned before any work is done, so you need
not worry about its state being altered by this method.
trigg
- The trigger upon which to do the workcal
- The calendar to apply to the trigger's schedulenumTimes
- The number of next fire times to produce
public static java.util.List computeFireTimesBetween(Trigger trigg, Calendar cal, java.util.Date from, java.util.Date to)
Trigger
that fall within the given date range. The input trigger will be cloned
before any work is done, so you need not worry about its state being
altered by this method.
trigg
- The trigger upon which to do the workcal
- The calendar to apply to the trigger's schedulefrom
- The starting date at which to find fire timesto
- The ending date at which to stop finding fire times
|
Quartz Project Page | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |