Getting error java.text.ParseException: Unparseable date: (at offset 0) even if the Simple date format and string value are identical

后端 未结 3 1293
Happy的楠姐
Happy的楠姐 2020-11-27 08:44

I\'m always getting the parse exception even if the format to check and the string value are same. Here is the code:

String format = \"EEE MMM dd HH:mm:ss z          


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 09:08

    I use the almost use the same code as you do with only slight difference in SimpleDateFormat instantiation.

    public static final String DATE_FORMAT = "EEE MMM d yyyy z HH:mm:ss";
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(DATE_FORMAT, Locale.ROOT);
    simpleDateFormat.format(date);
    

    It returns Mon Sep 18 2017 GMT+03:00 23:04:10.

提交回复
热议问题