public class Schedule extends Object
Schedule
generates a series of time events.
Create a schedule using one of the factory methods:
createOnce(java.util.Date, java.util.TimeZone)
,createDaily(java.util.Date, java.util.Date, java.util.TimeZone, java.sql.Time, int)
,createWeekly(java.util.Date, java.util.Date, java.util.TimeZone, java.sql.Time, int, int)
,createMonthlyByDay(java.util.Date, java.util.Date, java.util.TimeZone, java.sql.Time, int, int)
,createMonthlyByWeek(java.util.Date, java.util.Date, java.util.TimeZone, java.sql.Time, int, int, int)
. Then use the nextOccurrence(java.util.Date, boolean)
method to find the next occurrence
after a particular point in time.
The begin
and end
parameters represent the
points in time between which the schedule is active. Both are optional.
However, if a schedule type supports a period
parameter, and
you supply a value greater than 1, begin
is used to determine
the start of the cycle. If begin
is not specified, the cycle
starts at the epoch (January 1st, 1970).
The Date
parameters in this API -- begin
and
end
, the time
parameter to createOnce(java.util.Date, java.util.TimeZone)
,
and the earliestDate
parameter and value returned from nextOccurrence(java.util.Date, boolean)
-- always represent a point in time (GMT), not a local
time. If a schedule is to start at 12 noon Tokyo time, April 1st, 2002, it
is the application's reponsibility to convert this into a UTC Date
value.
Modifier and Type | Field and Description |
---|---|
static int |
LAST_DAY_OF_MONTH
Indicates that a schedule should fire on the last day of the month.
|
static int |
LAST_WEEK_OF_MONTH
Indicates that a schedule should fire on the last week of the month.
|
Modifier and Type | Method and Description |
---|---|
static Schedule |
createDaily(Date begin,
Date end,
TimeZone tz,
Time timeOfDay,
int period)
Creates a calendar which fires every day.
|
static Schedule |
createMonthlyByDay(Date begin,
Date end,
TimeZone tz,
Time timeOfDay,
int period,
int daysOfMonthBitmap)
Creates a calendar which fires on particular days of each month.
|
static Schedule |
createMonthlyByWeek(Date begin,
Date end,
TimeZone tz,
Time timeOfDay,
int period,
int daysOfWeekBitmap,
int weeksOfMonthBitmap)
Creates a calendar which fires on particular days of particular weeks of
a month.
|
static Schedule |
createOnce(Date date,
TimeZone tz)
Creates a calendar which fires only once.
|
static Schedule |
createWeekly(Date begin,
Date end,
TimeZone tz,
Time timeOfDay,
int period,
int daysOfWeekBitmap)
Creates a calendar which fires on particular days each week.
|
Date |
nextOccurrence(Date after,
boolean strict)
Returns the next occurrence of this schedule after a given date.
|
public static final int LAST_DAY_OF_MONTH
public static final int LAST_WEEK_OF_MONTH
public static Schedule createOnce(Date date, TimeZone tz)
date
- date and time to fire, must be UTCtz
- timezonepublic static Schedule createDaily(Date begin, Date end, TimeZone tz, Time timeOfDay, int period)
begin
- open lower bound, may be null, must be UTCend
- closed upper bound, may be null, must be UTCtz
- timezonetimeOfDay
- time at which to fireperiod
- causes the schedule to fire every period
days. If period
is greater than 1, the cycle starts
at the begin point of the schedule, or at the epoch (1 January,
1970) if begin
is not specified.public static Schedule createWeekly(Date begin, Date end, TimeZone tz, Time timeOfDay, int period, int daysOfWeekBitmap)
tz
- timezonedaysOfWeekBitmap
- a bitmap of day values, for example
(1 << Calendar.TUESDAY
) |
(1 << Calendar.THURSDAY
)
to fire on Tuesdays
and ThursdaystimeOfDay
- time at which to firebegin
- open lower bound, may be nullend
- closed upper bound, may be nullperiod
- causes the schedule to be active every period
weeks. If period
is greater than 1, the cycle starts
at the begin point of the schedule, or at the epoch (1 January,
1970) if begin
is not specified.public static Schedule createMonthlyByDay(Date begin, Date end, TimeZone tz, Time timeOfDay, int period, int daysOfMonthBitmap)
creates a schedule which fires on the 12th, 14th and last day of the month.createMonthlyByDay( null, null, TimeZone.getTimeZone("PST"), 1, (1 << 12) | (1 << 14) | (1 <<LAST_DAY_OF_MONTH
))
begin
- open lower bound, may be nullend
- closed upper bound, may be nulltz
- timezonedaysOfMonthBitmap
- a bitmap of day values, may include
LAST_DAY_OF_MONTH
timeOfDay
- time at which to fireperiod
- causes the schedule to be active every period
months. If period
is greater than 1, the cycle starts
at the begin point of the schedule, or at the epoch (1 January,
1970) if begin
is not specified.public static Schedule createMonthlyByWeek(Date begin, Date end, TimeZone tz, Time timeOfDay, int period, int daysOfWeekBitmap, int weeksOfMonthBitmap)
creates a schedule which fires on the 2nd and last Tuesday and Thursday of the month.createMonthlyByWeek( null, null, TimeZone.getTimeZone("PST"), (1 << Calendar.TUESDAY) | (1 << Calendar.THURSDAY), (1 << 2) | (1 <<LAST_WEEK_OF_MONTH
)
begin
- open lower bound, may be nullend
- closed upper bound, may be nulltz
- timezonedaysOfWeekBitmap
- a bitmap of day values, for example
(1 << Calendar.TUESDAY) | (1 << Calendar.THURSDAY)
weeksOfMonthBitmap
- a bitmap of week values (may include
LAST_WEEK_OF_MONTH
timeOfDay
- time at which to fireperiod
- causes the schedule be active every period
months. If period
is greater than 1, the cycle starts
at the begin point of the schedule, or at the epoch (1 January,
1970) if begin
is not specified.public Date nextOccurrence(Date after, boolean strict)
after
is null, returns the first occurrence. If there are
no further occurrences, returns null.after
- if not null, returns the first occurrence after this
point in time; if null, returns the first occurrence ever.strict
- If after
is an occurrence,
strict
determines whether this method returns it, or
the next occurrence. If strict
is true, the value
returned is strictly greater than after
.Copyright © 2018 Hitachi Vantara. All rights reserved.