public static void main(String[] args) {
long d=new Date().getTime();
}
这样获得的是long型的
怎么转换成2000-10-10 hh:mm:ss
这样的?
程序不要自己写,用jar包中的方法直接获取的那种
long d=new Date().getTime();
}
这样获得的是long型的
怎么转换成2000-10-10 hh:mm:ss
这样的?
程序不要自己写,用jar包中的方法直接获取的那种
System.out.println(dateFormat.format(d));
不行,输出的也是long型的
import java.text.SimpleDateFormat;
import java.util.Date;public class test7 { public static void main(String[] args) {
long d=new Date().getTime();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(dateFormat.format(d));
}}
结果:
2012-12-26 13:47:54
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(dateFormat.format(new Date(System.currentTimeMillis())));