Timer timer = new Timer();
TimerTask timerTask = new TimerTask() {
@Override
public void run() {
String time = new SimpleDateFormat("HH:mm:ss")
.format(new Date());
System.out.println("Now Time : " + time);
}
};
timer.schedule(timerTask, 2000, 3000);
时间: 2024-10-10 08:49:33