Java Reference
In-Depth Information
the timer was set this way; otherwise, isCalendarTimer throws an IllegalStateException
exception.
You can determine information about the timer's persistent state by using the isPersistent
method. Similarly, you can obtain information about the time by calling the getInfo method.
Timers are automatically cancelled when they expire. The container cancels the single‐event timers,
and you can cancel scheduled timers by calling the cancel method on the Timer object.
Timer Expression
Both programmatic and automatic timers can use calendar‐based timer attributes. Table 10-3 shows
the range of timer attributes that are used to set the timers. For automatic calendar‐based timers,
you set the calendar attributes in the annotation, whereas programmatic calendar‐based timers use
methods of the ScheduleExpression class to set the calendar attribute values.
TABLE 10-3: Calendar‐Based Expressions
ATTRIBUTE
DESCRIPTION
PERMITTED VALUES
One or more seconds within a
minute
0 through 59
second
One or more minutes within an
hour
0 through 59
minute
One or more hours within a day
0 through 23
hour
One or more days within a week
0 through 7 (0 and 7 refer to Sunday)
Sun through Sat
dayOfWeek
One or more days within a month
1 through 31
-7 through -1 (days from end of month)
Last
1st, 2nd, 3rd ‐ nth
Sun through Sat
dayOfMonth
One or more months within a
year
1 through 12
Jan through Dec
month
A particular calendar year
2014, 2015, etc.
year
It's worth noting that the default value for the time attributes is 0 (zero) and for the non‐numerical
values it is * (asterisk).
This table has been appropriated from the Oracle's Java EE 7 tutorial. 2 The syntax is cron‐like
and should be familiar to most programmers. There are a few interesting characteristics worth
pointing out.
 
Search WWH ::




Custom Search