package javatest;
import java.text.SimpleDateFormat;
import java.util.Date; class timeTest{
public static void main(String[] args){
//获取当前时间
Date start=new Date();
//格式化日期、时间
SimpleDateFormat df=new SimpleDateFormat("yyyyMMddHHmmss");
//String s=String.format("yyyy-MM-dd", dt);
String s=df.format(start);
System.out.println(s); //计算时间差
Date end=new Date();
long diff = end.getTime() - start.getTime();
String info=String.format("it takes %f seconds to run.", diff / 1000.00);
System.out.println(info);
}
}