aspose 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: 18907
    
    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: 3018
    
  10
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.
 
Don't get me started about those stupid light bulbs.
 
subject: Java Timer with Day light Savings