日期:2014-05-20 浏览次数:20662 次
Date now = new Date();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long now_long = now.getTime();// 13
System.out.println("现在时间是:" + df.format(now));
long now_long_1000 = now_long/1000;
System.out.println("现在时间的毫秒 :" + now_long);
System.out.println("现在时间的毫秒/1000:" + now_long_1000);
System.out.println("由13位long型转换回去的:" + df.format(new Date(now_long)));
System.out.println("由10位long型转换回去的:" + df.format(new Date(now_long_1000 * 1000)));
// 结果
现在时间是:2013-04-11 10:49:03
现在时间的毫秒 :1365648543084
现在时间的毫秒/1000: 1365648543
由13位long型转换回去的:2013-04-11 10:49:03
由10位long型转换回去的:2013-04-11 10:49:03