This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question on Automatic Timer creation suing @schedule annotation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question on Automatic Timer creation suing @schedule annotation" Watch "Question on Automatic Timer creation suing @schedule annotation" New topic
Author

Question on Automatic Timer creation suing @schedule annotation

Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634


Source:EJB 3.1 Specification


18.2.1.3.9 "Every other hour within the day starting at noon on the 2nd Tuesday of every month."

@Schedule(hour="12/2", dayOfMonth="2nd Tue")

Question 1:Why is it mentioned that timer will run every other hour ?
As per my understanding,The above created timer will run every 2 hr within the day starting at noon on the 2nd Tuesday of every month


OCPJP 6.0 93%
OCPJWCD 5.0 98%
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1686
    
  25

Hi Mohit,

"every other hour" means "every second".

Regards,
Frits
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

"every other hour" means "every second".


Then shouldn't the Schedule annotation be as:



Question: Why are we using hour="12/2" ?
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1686
    
  25

Sorry, I meant 2nd, not seconds...

Why are we using hour="12/2" ?

This is because:

For expression x/y, the attribute is constrained to every yth value within the set of allowable values beginning at time x

So, in our example 12/2: every two hours starting at noon

Regards,
Frits
Mohit G Gupta
Ranch Hand

Joined: May 18, 2010
Posts: 634

Thanks Frits
 
GeeCON Prague 2014
 
subject: Question on Automatic Timer creation suing @schedule annotation