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 );
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)