The purpose of this example is to demonstrate the various combinations of operators that you can use in the CronEntry fields.
The values of the fields in the following CronEntry have the meaning outlined in the table below:
CronEntry ce = new CronEntry ("2007,2008:*/3:*:6,7:8-10,12-14:*/15,32") |
By using this constructor, the CronEntry is executed in the current time zone of the local machine. In this example, the time zone is set to GMT.
Field Values Meaning
Field |
Value |
Meaning |
Year |
2007,2008 |
Run in years 2007 and 2008 |
Month |
*/3 |
Run every third month of the year, counting from 0, which is months 0, 3, 6, 9, or January, April, July, and October. |
Day of Month |
* |
The value of Day of Week is taken into consideration, because Day of Month is * while Day of Week is specified. |
Day of Week |
6,7 |
Run every Friday and Saturday |
Hour |
8-10,12-14 |
Run between 8 AM and 10 AM and then between 12 PM and 2 PM |
Minute |
*/15,32 |
Run every quarter of an hour and every 32 minutes past the hour within the ranges specified in the Hour field. |
The snippet below shows the exact execution times of the CronEntry for the first Friday and par of Saturday in 2007.
Iteration Execution Time
1 Fri Jan 05 08:00:00 GMT 2007 2 Fri Jan 05 08:15:00 GMT 2007 3 Fri Jan 05 08:30:00 GMT 2007 4 Fri Jan 05 08:32:00 GMT 2007 5 Fri Jan 05 08:45:00 GMT 2007 6 Fri Jan 05 09:00:00 GMT 2007 7 Fri Jan 05 09:15:00 GMT 2007 8 Fri Jan 05 09:30:00 GMT 2007 9 Fri Jan 05 09:32:00 GMT 2007 10 Fri Jan 05 09:45:00 GMT 2007 11 Fri Jan 05 10:00:00 GMT 2007 12 Fri Jan 05 10:15:00 GMT 2007 13 Fri Jan 05 10:30:00 GMT 2007 14 Fri Jan 05 10:32:00 GMT 2007 15 Fri Jan 05 10:45:00 GMT 2007 16 Fri Jan 05 12:00:00 GMT 2007 17 Fri Jan 05 12:15:00 GMT 2007 18 Fri Jan 05 12:30:00 GMT 2007 19 Fri Jan 05 12:32:00 GMT 2007 20 Fri Jan 05 12:45:00 GMT 2007 21 Fri Jan 05 13:00:00 GMT 2007 22 Fri Jan 05 13:15:00 GMT 2007 23 Fri Jan 05 13:30:00 GMT 2007 24 Fri Jan 05 13:32:00 GMT 2007 25 Fri Jan 05 13:45:00 GMT 2007 26 Fri Jan 05 14:00:00 GMT 2007 27 Fri Jan 05 14:15:00 GMT 2007 28 Fri Jan 05 14:30:00 GMT 2007 29 Fri Jan 05 14:32:00 GMT 2007 30 Fri Jan 05 14:45:00 GMT 2007 31 Sat Jan 06 08:00:00 GMT 2007 32 Sat Jan 06 08:15:00 GMT 2007 33 Sat Jan 06 08:30:00 GMT 2007 34 Sat Jan 06 08:32:00 GMT 2007 … … |