Class Schedule
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.
- Since:
- May 7, 2002
- Author:
- jhyde
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Indicates that a schedule should fire on the last day of the month.static final int
Indicates that a schedule should fire on the last week of the month. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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.nextOccurrence
(Date after, boolean strict) Returns the next occurrence of this schedule after a given date.
-
Field Details
-
LAST_DAY_OF_MONTH
public static final int LAST_DAY_OF_MONTHIndicates that a schedule should fire on the last day of the month. -
LAST_WEEK_OF_MONTH
public static final int LAST_WEEK_OF_MONTHIndicates that a schedule should fire on the last week of the month.
-
-
Method Details
-
createOnce
Creates a calendar which fires only once.- Parameters:
date
- date and time to fire, must be UTCtz
- timezone
-
createDaily
Creates a calendar which fires every day.- Parameters:
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 everyperiod
days. Ifperiod
is greater than 1, the cycle starts at the begin point of the schedule, or at the epoch (1 January, 1970) ifbegin
is not specified.
-
createWeekly
public 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.- Parameters:
tz
- timezonedaysOfWeekBitmap
- a bitmap of day values, for example(1 <<
to fire on Tuesdays and ThursdaysCalendar.TUESDAY
) | (1 <<Calendar.THURSDAY
)timeOfDay
- time at which to firebegin
- open lower bound, may be nullend
- closed upper bound, may be nullperiod
- causes the schedule to be active everyperiod
weeks. Ifperiod
is greater than 1, the cycle starts at the begin point of the schedule, or at the epoch (1 January, 1970) ifbegin
is not specified.
-
createMonthlyByDay
public 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. For example,createMonthlyByDay( null, null, TimeZone.getTimeZone("PST"), 1, (1 << 12) | (1 << 14) | (1 <<
LAST_DAY_OF_MONTH
))- Parameters:
begin
- open lower bound, may be nullend
- closed upper bound, may be nulltz
- timezonedaysOfMonthBitmap
- a bitmap of day values, may includeLAST_DAY_OF_MONTH
timeOfDay
- time at which to fireperiod
- causes the schedule to be active everyperiod
months. Ifperiod
is greater than 1, the cycle starts at the begin point of the schedule, or at the epoch (1 January, 1970) ifbegin
is not specified.
-
createMonthlyByWeek
public 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. For example,createMonthlyByWeek( null, null, TimeZone.getTimeZone("PST"), (1 << Calendar.TUESDAY) | (1 << Calendar.THURSDAY), (1 << 2) | (1 <<
LAST_WEEK_OF_MONTH
)- Parameters:
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 includeLAST_WEEK_OF_MONTH
timeOfDay
- time at which to fireperiod
- causes the schedule be active everyperiod
months. Ifperiod
is greater than 1, the cycle starts at the begin point of the schedule, or at the epoch (1 January, 1970) ifbegin
is not specified.
-
nextOccurrence
Returns the next occurrence of this schedule after a given date. Ifafter
is null, returns the first occurrence. If there are no further occurrences, returns null.- Parameters:
after
- if not null, returns the first occurrence after this point in time; if null, returns the first occurrence ever.strict
- Ifafter
is an occurrence,strict
determines whether this method returns it, or the next occurrence. Ifstrict
is true, the value returned is strictly greater thanafter
.
-