java定时器控制时间打印
1 public class test2 { 2 public static void main(String []args){ 3 Timer timer=new Timer(); 4 timer.schedule(new TimerTask(){ 5 6 7 @Override 8 public void run() { 9 // TODO Auto-generated method stub 10 SimpleDateFormat sdf = new SimpleDateFormat("yyyyyyyy-MM-dd HH(hh):mm:ss S E D F w W a k K z"); 11 long times = System.currentTimeMillis(); 12 Date date = new Date(times); 13 String tim = sdf.format(date); 14 System.out.println(times+"-----------"+tim); 15 } 16 17 }, 0,10); 18 } 19 20 }
转载注明出处
如果本文对你有帮助,请帮忙啦~~
打开支付宝首页搜“522901509”领红包,领到大红包的小伙伴赶紧使用哦!