EJB timer service run every two hours but once a day not

1.6k Views Asked by At

I need a timer to be run every two hours.
But once a day at 4 o'clock the timer should be skipped.
The idea was to explicitly write every hour into the schedule annotation:

@Schedule( hour = "0, 2, 6, 8, 10, 12, 14, 16, 18, 20, 22", minute = "0" )

Which brings me to my question if there is a shorter way to express the timer?

1

There are 1 best solutions below

0
On

I think you can use intervals, from the EJB Timer Documentation i have found the following expression:

The following expression represents every 2 hours starting at noon:

hour="12/2"

So i think you can use something like this:

hour="0-2/2, 6-0/2"

I'm not sure this would work but you can give a try, or you can try combining the results using the documentation to find the correct output.