try {
SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss");
Date parse = format.parse("2019年06月26日 17:44:00");
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
System.out.println("5秒执行一次");
}
}, parse, 1000*5);
} catch (ParseException e) {
e.printStackTrace();
}
}
如果当前时间晚于设定时间,那么会补充相应时间的操作
Last modification:June 26th, 2019 at 05:46 pm
© The copyright belongs to the author
Comment here is closed