File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Java Timer with Day light Savings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Timer with Day light Savings" Watch "Java Timer with Day light Savings" New topic
Author

Java Timer with Day light Savings

Radha Gopal
Greenhorn

Joined: Feb 05, 2012
Posts: 13
Hi,

I need to have timer that runs at 9 PM daily. I ahve used the Java timer scheduleAtFixedRate with a 24 hour delay between the runs.

But , when the day light savings occurs, it is going to run either an hour before or hour later. is there any means to make it run at the exact same time ?

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

The solution that comes to my mind is to have a task which runs every hour on the hour, and which works like "If the time is (close to) 9 PM then do (whatever it is)".
Radha Gopal
Greenhorn

Joined: Feb 05, 2012
Posts: 13
Thanks Paul Clapham for your response ..
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2969
    
    9
It may be worthwhile to use Quartz for this. Neither Timer nor ScheduledThreadPoolExecutor supports what you want directly. Either roll your own as Paul C advises, or use a third-party library like Quartz.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java Timer with Day light Savings
 
Similar Threads
java.util.Timer and timezone switch
TimerTask set to 1 day
OS Clock
Does Java TimeZone takes care of daylight savings?
Change Timezone from GMT to EST, the best way to accomplish?