【原创】Java中将2019-05-13T06:31:57.790Z这种时间格式转化成本地时间格式yyyy-MM-dd HH:mm:ss

匿名 (未验证) 提交于 2019-12-02 21:35:18

解决方法:(String类型无法直接parse为一个date类型,所以需要先把String字符串,格式化为一个date类型,最后再格式化为你想要的格式)

 public String formatDate(String inputDate){         try{             DateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);             DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX", Locale.US);             Date date = inputFormat.parse(inputDate);             return outputFormat.format(date);         }catch (Exception e){             e.printStackTrace();             return null;         }     }

文章来源: https://blog.csdn.net/Kevin_Gu6/article/details/90210560
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!