Posted By:
Fred_Gracely
Posted On:
Thursday, November 29, 2001 07:25 AM
Using java.util.Timer, you can specify that a TimerTask object be executed at a specific time. Here is a code snippet:
//Get the Date corresponding to 11:01:00 pm today.
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 1);
calendar.set(Calendar.SECOND, 0);
Date time = calendar.getTime();
timer = new Timer();
timer.schedule(new [TimerTask Class Name], time);
To establish repeated execution, you should probably use one of the
scheduleAtFixedRate Timer methods.
More information is available at:
http://java.sun.com/docs/books/tutorial/essential/threads/timer.html
Hope this helps.