Java Reference
In-Depth Information
In this example, the timer will fire on every second of every minute, of every day, of every
month, of every year. This example isn't terribly useful but shows that each attribute sup-
ports the wildcard.
List
The list expression is composed of single values separated by a comma. The list can contain
duplicate entries but they're simply ignored. Whitespace between commas and the val-
ues are also ignored. A list can't contain a wildcard, sublists, or increments. But a list can
contain a range; for instance, you could specify Monday through Tuesday and Thursday
through Friday. The following is an example:
@Schedule(second="0,29", minute="0,14,29,59", hour="0,5,11,17",
dayOfMonth="1,15-31",year="2011,2012,2013")
This timer will execute for the years 2011, 2012, and 2013 on the first and for days 15-31,
every 6 hours, every 15 minutes of those hours, and every 30 seconds. The timer will thus
fire on 0:0:0 1, 2011, as well as 0:0:29 1, 2011, and so on. Note that dayOfWeek was
omitted to simplify the already complex example.
Range
You've already seen examples of ranges in the example on lists. A range enables you to
specify an inclusive set of values. A single value is separated by a dash ( - ), where the value
preceding the dash is the start value and the value after the dash is the end value. A range
may not contain the wildcard, lists, or increments. Here's a simple example using ranges:
@Schedule(hour="0-11",dayOfMonth="15-31",dayOfWeek="Mon-Fri",month="11-12",
year="2010-2020")
In this example the timer is going to execute for years 2011-2020, for the months of
November and December, for days Monday through Friday of the last half of the month,
and from midnight until noon. Ranges can also be used for the minutes , seconds , and
dayOfWeek attributes, but this would have made this example too complex.
Increments
Increment support enables the creation of timers that execute at fixed intervals. It's com-
posed of a forward slash, where the value preceding the slash specifies the starting point
Search WWH ::




Custom Search