哦。这个简单。Java中Date的时间,是从1970年1月1日0时0分0秒开始计算的毫秒数。 所以,转换的时候乘以一千即可。尝试 new Date(1278902362*1000);
已经解决: GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(times * 1000); java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); return format.format(gc.getTime());
Date date = new Date(1278902362*1000); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); System.out.println("format=="+format.format(date));
输出结果是:format==1969-12-20 06:48:27
再乘以 1000Date date = new Date(1278902362L * 1000);
GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(times * 1000); java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); return format.format(gc.getTime());
所以,转换的时候乘以一千即可。尝试 new Date(1278902362*1000);
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(times * 1000);
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return format.format(gc.getTime());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
System.out.println("format=="+format.format(date));
输出结果是:format==1969-12-20 06:48:27
再乘以 1000Date date = new Date(1278902362L * 1000);
gc.setTimeInMillis(times * 1000);
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
return format.format(gc.getTime());