Java ParseException while attempting String to Date parsing

前端 未结 5 1048
生来不讨喜
生来不讨喜 2021-01-20 08:32

I\'m having a hard time Parsing/Formatting a Date string received back from a web service. I\'ve attempted multiple approaches, but with no luck.

Sample Dat

5条回答
  •  [愿得一人]
    2021-01-20 09:02

    SimpleDateFormat isoDateFormat = new SimpleDateFormat("yyyy-mm-dd'T'hh:mm:ss'Z'");
    SimpleDateFormat viewFriendlyDateFormat = new SimpleDateFormat("dd/MMM/yyyy hh:mm:ss aaa");
    String viewFriendlyDate = "";
    try { 
        Date date = isoDateFormat.parse(timestamp);
        viewFriendlyDate = viewFriendlyDateFormat.format(date);
    
    } catch (ParseException e) { 
        e.printStackTrace(); 
    } 
    

提交回复
热议问题