This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Java in General and the fly likes Need a program in timer schedule.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Need a program in timer schedule.." Watch "Need a program in timer schedule.." New topic

Need a program in timer schedule..

sridhar Ranganathan

Joined: Feb 06, 2008
Posts: 29
I need a timer schedule program for executing daily basic task.
time :- 5:30 AM

Joanne Neal

Joined: Aug 05, 2005
Posts: 3742
Take a look at the Timer and TimerTask classes.

Thomas Bennett

Joined: Jan 09, 2007
Posts: 12
Look at the java.util.Timer class along with TimerTask
Nikhil Jain
Ranch Hand

Joined: May 15, 2005
Posts: 385

SCJP 1.4, SCWCD 1.4, SCBCD 1.5
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 41084
You might be up and about at 5:30 am, but I'm not. Please check how many 0s you have after 864; if that's milliseconds then I think you have 2hrs 24min, ie 0.1 day.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19908

I usually opt for letting the OS schedule those kinds of tasks. Window's task scheduler or Linux' / Unix' cron work just fine for me.

How To Ask Questions How To Answer Questions
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 691
Instead of coding a literal constant (8640000) that no one knows the value of or why its being used, why not code an expression with all its terms to make it obvious what the number means. For exampel: 24*7*1000 or whatever.
Rob Spoor

Joined: Oct 27, 2005
Posts: 19908

Even better, make it a constant with the calculation in it:
public static final int DAY_IN_MILLIS = 24 * 60 * 60 * 1000;

That way, you get the clarity, plus its evaluated by the compiler and stored as 86,400,000 in the class file.
wood burning stoves
subject: Need a program in timer schedule..