public static Date TimestampToDate(Integer time){
long temp = (long)time*1000;
Timestamp ts = new Timestamp(temp);
Date date = new Date();
try {
date = ts;
//System.out.println(date);
} catch (Exception e) {
e.printStackTrace();
}
return date;
}
//int 转时间戳
public static String timestampToString(Integer time){
//int转long时,先进行转型再进行计算,否则会是计算结束后在转型
long temp = (long)time*1000;
Timestamp ts = new Timestamp(temp);
String tsStr = "";
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
//方法一
tsStr = dateFormat.format(ts);
System.out.println(tsStr);
} catch (Exception e) {
e.printStackTrace();
}
return tsStr;
}