public static void main(String[] args) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(1562205642);
System.out.printf(simpleDateFormat.format(date));
Date date1 = new Date(1562205642*1000L);
System.out.printf("\n"+simpleDateFormat.format(date1));
}
1970-01-19 09:56:45
2019-07-04 10:00:42
代码一对比,就看出问题了,为什么要乘以一千,是因为java解析时间是13位,而这个时间戳是十位,所以需要乘于1000