package cn.zy;
import java.util.Date;
import java.text.SimpleDateFormat;
public class Demo01 {
public static void main(String[] args) {
class OneThread extends Thread{
@Override
public void run() {
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
while(true){
Date d=new Date();
String str=sdf.format(d);
System.err.println(str);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
OneThread one=new OneThread();
one.start();
}
}
转载于:https://my.oschina.net/saysuqi/blog/640065