Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## BEA WebLogic Server 9.0 API Reference

## weblogic.jms.extensions
Class Schedule

    java.lang.Object
      weblogic.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:

- If multiple schedules are supplied (using a semi-colon (;) as the separator), the next scheduled time for the set is determined using the schedule that returns the soonest value. One use for this is for specifying schedules that change based on the day of the week (see the final example below).
- A value of 1 (one) for the dayOfWeek equates to Sunday.
- A value of '*' means every time for that field. For instance, a '*' in the Month field means every month. A '*' in the Hour field means every hour.
- A value of 'l', or 'last' (case insensitive) indicates the greatest possible value for a field.
- If a day-of-month is specified that exceeds the normal maximum for a month, then the normal maximum for that month will be specified. For example, if it is February during a leap year and 31 was specified, then the scheduler will schedule as if 29 was specified instead. This means that setting the month field to 31 always indicates the last day of the month.
- If milliseconds are specified, they are rounded down to the nearest 50th of a second. The values are 0, 19, 39, 59, ..., 979, and 999. Thus '0-40' gets rounded to '0-39', and '50-999' gets rounded to '39-999'.

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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://e-docs.bea.com/wls/docs90 Copyright 2005 BEA Systems Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD