Java String to Date, ParseException

后端 未结 3 1953
清歌不尽
清歌不尽 2021-01-29 05:21

I have a string named DateCompareOld, it has the value \"Fri Aug 12 16:08:41 EDT 2011\". I want to convert this to a date object.

 SimpleDateFormat          


        
3条回答
  •  余生分开走
    2021-01-29 05:54

    DateFormat dateType =  new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
    dateType.setLenient(false);
    Date convertDate = dateType.parse(DateCompareOld);
    

提交回复
热议问题