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


Win a copy of Head First Android this week in the Android forum!
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
Sheriff

Joined: Oct 14, 2005
Posts: 19659
    
  10

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: 3025
    
  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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java Timer with Day light Savings
 
It's not a secret anymore!