做地方网站能赚钱吗,赛扶做网站,重装wordpress图片不见了,学做烘焙网站#x1f61c;作 者#xff1a;是江迪呀✒️本文关键词#xff1a;日常BUG、BUG、问题分析☀️每日 一言 #xff1a;存在错误说明你在进步#xff01; 一、问题描述
long类型的日期为#xff1a;1646718195 装换为date类型#xff1a;
Date date new Dat… 作 者是江迪呀✒️本文关键词日常BUG、BUG、问题分析☀️每日 一言 存在错误说明你在进步 一、问题描述
long类型的日期为1646718195 装换为date类型
Date date new Date(1646718195);
System.out.println(DateFormatUtils.format(date,yyyy-MM-dd HH:mm:ss));
//输出结果
1970-01-20 09:25:18二、问题原因
我们可以看到new Date(long)此构造函数
/*** Allocates a codeDate/code object and initializes it to* represent the specified number of milliseconds since the* standard base time known as the epoch, namely January 1,* 1970, 00:00:00 GMT.** param date the milliseconds since January 1, 1970, 00:00:00 GMT.* see java.lang.System#currentTimeMillis()*/
public Date(long date) {fastTime date;
}三、问题解决
Date date new Date(Long.valueOf(1646718195)*1000);
System.out.println(DateFormatUtils.format(date,yyyy-MM-dd HH:mm:ss));
//输出结果
1970-01-20 09:25:1