This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons 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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    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: 2995
    
    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.
 
 
subject: Java Timer with Day light Savings
 
Similar Threads
Change Timezone from GMT to EST, the best way to accomplish?
Does Java TimeZone takes care of daylight savings?
java.util.Timer and timezone switch
OS Clock
TimerTask set to 1 day