TimerTask task = new TimerTask() {
// 要执行的任务
};
//设置执行时间
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH);
int day = calendar.get(Calendar.DAY_OF_MONTH);
//每天//定制每天的00:00:00执行,
calendar.set(year, month, day, 00, 00, 00);
Date date = calendar.getTime();
Timer timer = new Timer();System.out.println(date);
// 执行时间15分钟一次int period = 750 * 1000;
//每天的date时刻执行task,每隔750秒重复执行
timer.schedule(task, date, period);
// //每天的date时刻执行task, 仅执行一次//
//timer.schedule(task, date);