import java.text.SimpleDateFormat;
import java.util.Date;
public class Demo03 {
public static void main(String[] args) {
Date date = new Date(System.currentTimeMillis());
while (true){
try {
Thread.sleep(1000);
System.out.println(new SimpleDateFormat("HH:mm:ss").format(date));
date=new Date(System.currentTimeMillis());//更新当前时间
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
}