• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need a program in timer schedule..

 
sridhar Ranganathan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need a timer schedule program for executing daily basic task.
time :- 5:30 AM

Thanks,
Sridhar.R
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the Timer and TimerTask classes.
 
Thomas Bennett
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the java.util.Timer class along with TimerTask
 
Nikhil Jain
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Campbell Ritchie
Sheriff
Pie
Posts: 49827
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Norm Radder
Bartender
Posts: 1239
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20611
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic