时间戳类型转换

public void testFormat(String paramStr){
SimpleDateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”);
long longTime = new Long(paramStr); //时间戳转long
日期longDate = new Date(longTime); // long转日期
字符串dateStr = dateFormat.format(longTime); // Date转String
try {
Date formatDate = dateFormat.parse(dateStr); // String转指定格式的日期类型
} catch(ParseException e){
e.printStackTrace();

}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章