异常:java.text.ParseException: Unparseable date: “1635758308221“

异常:java.text.ParseException: Unparseable date: “1635758308221“,第1张

异常:java.text.ParseException: Unparseable date: “1635758308221“
2021-11-01 17:18:28.225 ERROR 44444 --- [nio-8088-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.text.ParseException: Unparseable date: "1635758308221"] with root cause

java.text.ParseException: Unparseable date: "1635758308221"

原代码

String nowDate = String.valueOf(System.currentTimeMillis());
Date date =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(nowDate);

解决办法:

Date date;
try {
    date = DateUtil.string2Date(nowDate, DateUtil.yyyy_MM_dd_HH_mm_ss);
} catch (Exception e) {
    date = null;
}
System.out.println(date );
       

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4970028.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-13
下一篇 2022-11-14

发表评论

登录后才能评论

评论列表(0条)

保存