Import Java.util.TimerTask;
/**
*
@author ADMIN_HZW * */
public
class Task extends TimerTask {public
void run () {
system.out.println ("I have a little donkey!");
}
Import Java.util.Calendar;
Import Java.util.Date;
Import Java.util.Timer; /** * Task Management * @author ADMIN_HZW * */public class Timermanager {/** * @param args/public static void main (St
Ring[] args) {new Timermanager ();
}//time interval (day) private static final Long Period_day = 24 * 60 * 60 * 1000;
Public Timermanager () {Calendar calendar = calendar.getinstance (); Calendar.set (Calendar.hour_of_day, 1);
1 o'clock in the morning Calendar.set (Calendar.minute, 0);
Calendar.set (Calendar.second, 0); Date Date=calendar.gettime (); Time of the first scheduled task//If the first time the scheduled task is performed is less than the current time//The first time a scheduled task is performed at a single day, so that the task is performed at the next point in time.
If the day is not added, the task is executed immediately.
if (Date.before (new Date ())) {date = This.addday (date, 1);
Timer timer = new timer ();
Task task = new Task ();
Schedules the specified task to begin repeating fixed-delay execution at a specified time.
Timer.schedule (Task,date,period_day);
//Increase or decrease the number of days public date addday (date date, int num) {Calendar STARTDT = calendar.getinstance ();
Startdt.settime (date); Startdt.add (Calendar.day_of_month, num);
return Startdt.gettime ();
}
}