/**
* 时间戳转日期
* @explain
* @param timstanp 时间戳可以为String类型,也可以为long类型
* @return yyyy-MM-dd HH:mm:ss 格式字符串
*
*/
public static String timestampToDate(Object timestamp){
long sjc = 0;
String dateStr = "";
if(timestamp instanceof String)
sjc =Long.parseLong((String)timestamp);
else if(timestamp instanceof Long)
sjc =(Long)timestamp;
else
return dateStr;
Date date = new Date(sjc);
SimpleDateFomart sdf = new SimpleDateFomart("yyyy-MM-dd HH:mm:ss");
dateStr =sdf.format(date);
return dateStr;
}
Java 获取时间戳三种方式
1. System.currentTimeMills()
2. new Date().getTime()
3. Calendar.getInstance().getTimeMillis()