Java【工具类】时间戳转化为正常格式的时间
程序员文章站
2022-03-27 17:11:02
...
JAVA代码转化时间戳
package com.test;
import java.util.Date;
import java.lang.annotation.Annotation;
import java.lang.reflect.*;
import java.text.SimpleDateFormat;
public class MainTest {
public static final String TIME_FORMATER = "yyyy-MM-dd HH:mm:ss";
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Long dateStr=1574202291473l;
testDateStr(dateStr);
}
public static void testDateStr(Long dateStr){
Date date=new Date(dateStr);
String normalDate=new SimpleDateFormat(TIME_FORMATER).format(date);
System.out.println("时间戳 : "+dateStr);
System.out.println("normalDate : "+normalDate);
}
/******
时间戳 : 1574202291473
normalDate : 2019-11-20 06:24:51
*/
下一篇: css动画的steps