1.date类的构造函数直接传入long型的数据:
long time = system.currenttimemillis()
date date = new date(time)2.使用calendar类的settime方法,传入long型的数据:
calendar ca = calendar.getinstance()
long time = system.currenttimemillis()
ca.settime(time )
date d = ca.gettime()
用java代码实现:
public static String longToDate(long lo){
Date date = new Date(lo)
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
return sd.format(date)
}
资料拓展:
长整型(long)是计算机程序语言,是程序设计中数据类型的一种表现方式,一般情况下用long 表示长整型。 long 有符号64位整数,范围是-2^63-2^63 -1 Int64。