Timer

1. I want to schedule a process to run at 12 midnight everyday. How do I do that by using Timer object? Or is there any other way? Sample code will be much helpful.

2. I use Timer.schedule(TimerTask task, Date time) function, but having problem to define the Date parameter. ex. I want to run it on 2002/04/30,
Date time = new Date(102,4,30), this doesn't work.

Thank you!
cHEoAsked:
Who is Participating?
 
NeutronConnect With a Mentor Commented:
hi cHEo, :-)

Valid month-value for Date is 0..11, not 1..12
maybe that is why your task execution was not triggered.
[unless you are prepared to wait till the end of may ;)]
However, you should use Calendar instead of date, because the constructor you're using is deprecated.

You can take a look at:
http://java.sun.com/docs/books/tutorial/essential/threads/timer.html

Greetings,
    </ntr> :)
0
 
girionisCommented:
Listening.
0
 
cHEoAuthor Commented:
where can I get some example for this topic in the web?
Providing URL will be great
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
cHEoAuthor Commented:
where can I get some example for this topic in the web?
Providing URL will be great
0
 
girionisCommented:
0
 
cHEoAuthor Commented:
where can I get some example for this topic in the web?
Providing URL will be great
0
 
NeutronCommented:
oops, girionis, sorry about that link O:-)
0
 
girionisCommented:
 It's all right :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.