BEA Systems, Inc.

BEA WebLogic Server 9.0 API Reference


weblogic.jms.extensions
Class Schedule

java.lang.Object
  extended byweblogic.jms.extensions.Schedule

public final class Schedule
extends Object

Time Scheduler

This class provides methods that take a schedule and a time and return the next scheduled time. A cron-like string is used to define the schedule. The format is specified in the following BNF syntax:

schedule := millisecond second minute hour dayOfMonth month dayOfWeek
The BNF syntax for specifying the second field is as follows:

second := * | secondList secondList := secondItem [, secondList] secondItem := secondValue | secondRange secondRange := secondValue - secondValue
Similar BNF statements for milliseconds, minute, hour, dayOfMonth, month, and dayOfWeek can be derived from the second syntax. The values for each field are defined as non-negative integers in the following ranges:

milliSecondValue := 0-999 secondValue := 0-59 minuteValue := 0-59 hourValue := 0-23 dayOfMonthValue := 1-31 monthValue := 1-12 dayOfWeekValue := 1-7
Note: These values equate to the same ranges that the java.util.Calendar class uses, except for 'monthValue'. The java.util.Calendar range for 'monthValue' is 0-11, rather than 1-12.

Using this syntax, each field can be represented as a range of values indicating all times between the two times. For example, "2-6" in the dayOfWeek field indicates Monday through Friday, inclusive. Each field can also be specified as a comma separated list. For instance, a minute field of "0,15,30,45" means every quarter hour on the quarter hour. Lastly, each field can be defined as both a set of individual values and ranges of values. For example, an hour field of "9-17,0" indicates between the hours of 9 am and 5 pm, and on the hour of midnight.

Additional semantics are as follows:

Note: When a Calendar is not supplied as a method parameter to one of the static methods in this class, the calendar used is a java.util.GregorianCalendar with a default java.util.TimeZone and a default java.util.Locale.

Examples:

"0 0 0,30 * * * *" Exact next nearest half-hour "* * 0,30 4-5 * * *" Anytime in the first minute of the half hours in the 4 and 5 o'clock AM hours "* * * 9-16 * * *" Between 9 AM and 5 PM (9:00.00 AM to 4:59.59PM) "* * * * 8-14 * 2" The second Tuesday of the month "* * * 13-16 * * 0" Between 1 PM and 5 pm on Sunday "* * * * * 31 *" The last day of the month "* * * * 15 4 1" The next time April 15th occurs on a Sunday "0 0 0 1 * * 2-6;0 0 0 2 * * 1,7" 1 AM on the weekdays, 2 AM on the weekends

See Also:
Calendar, GregorianCalendar, TimeZone
Copyright © 2005 BEA Systems, Inc. All Rights Reserved.

Constructor Summary
Schedule()
           
 
Method Summary
static void main(String[] args)
           Unsupported command line interface, may change without notice.
static Calendar nextScheduledTime(String schedule)
          The next scheduled time after the current time.
static Calendar nextScheduledTime(String schedule, Calendar calendar)
          Get the next scheduled time after the given time.
static long nextScheduledTimeInMillis(String schedule)
          The next scheduled time after the current time.
static long nextScheduledTimeInMillis(String schedule, long timeInMillis)
          The next scheduled time after the given time.
static long nextScheduledTimeInMillisRelative(String schedule)
          The next scheduled time after the current time.
static long nextScheduledTimeInMillisRelative(String schedule, long timeInMillis)
          Get the next scheduled time after the given time.
static void parseSchedule(String schedule)
          Throw a ParseException if the given schedule doesn't parse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Schedule

public Schedule()
Method Detail

main

public static void main(String[] args)
                 throws Exception
Unsupported command line interface, may change without notice.

Throws:
Exception

nextScheduledTime

public static Calendar nextScheduledTime(String schedule)
                                  throws ParseException
The next scheduled time after the current time.

Throws:
ParseException
See Also:
nextScheduledTime(String, Calendar)

nextScheduledTime

public static Calendar nextScheduledTime(String schedule,
                                         Calendar calendar)
                                  throws ParseException
Get the next scheduled time after the given time.

Returns:
The next scheduled time; a new instance of Calendar.
Throws:
ParseException - Syntax error in schedule.

nextScheduledTimeInMillis

public static long nextScheduledTimeInMillis(String schedule)
                                      throws ParseException
The next scheduled time after the current time.

Throws:
ParseException

nextScheduledTimeInMillis

public static long nextScheduledTimeInMillis(String schedule,
                                             long timeInMillis)
                                      throws ParseException
The next scheduled time after the given time. The return value is in absolute milliseconds.

Parameters:
timeInMillis - the time in UTC milliseconds from the epoch.
Returns:
The next scheduled time in UTC milliseconds from the epoch.
Throws:
ParseException

nextScheduledTimeInMillisRelative

public static long nextScheduledTimeInMillisRelative(String schedule)
                                              throws ParseException
The next scheduled time after the current time.

Throws:
ParseException
See Also:
nextScheduledTimeInMillisRelative(String, long)

nextScheduledTimeInMillisRelative

public static long nextScheduledTimeInMillisRelative(String schedule,
                                                     long timeInMillis)
                                              throws ParseException
Get the next scheduled time after the given time. The return value is in relative milliseconds.

Parameters:
timeInMillis - the time in UTC milliseconds from the epoch.
Returns:
The difference between the given time and the next scheduled time in milliseconds, which is always greater than or equal to 0.
Throws:
ParseException

parseSchedule

public static void parseSchedule(String schedule)
                          throws ParseException
Throw a ParseException if the given schedule doesn't parse.

Throws:
ParseException - Syntax error in schedule.

Documentation is available at
http://download.oracle.com/docs/cd/E13222_01/wls/docs90
Copyright 2005 BEA Systems Inc.