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 }

 

posted on 2016-08-09 11:58  山高似水深  阅读(995)  评论(0编辑  收藏  举报

购买方式 点击下面图标购买