import java.util.Calendar;
public class Test {
public static void main(String args[]){
//得到Calendar对象并获得系统时间距离1970.1.1的毫秒值
Calendar calendar = Calendar.getInstance();
long time = System.currentTimeMillis();
while (true){
//设置时间加一秒
time += 1000;
calendar.setTimeInMillis(time);
//输出年月日
System.out.print(String.format("%tF",calendar));
//输出星期
System.out.print(String.format(" %tA",calendar));
//输出时间
System.out.print(String.format(" %tT", calendar));
//换行
System.out.println();
//线程休眠1秒
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}