File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 1518
    
  22

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: 1518
    
  22

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on Automatic Timer creation suing @schedule annotation
 
Similar Threads
To run task once in a every month using servletcontextlistener
Schedule a Timer for (starting Date, No of times, no of days) problem
Schedule a Timer for (starting Date, No of times, no of days) problem
ever happen to you -- you watch the same program in a day twice??
Quartz scheduler or Timer task?