SimpleDateFormat - Unparseable date

前端 未结 4 660
野趣味
野趣味 2020-12-04 02:34

I try to convert String to Date.

Here is my code:

    SimpleDateFormat format =  new SimpleDateFormat(\"EEE MMM dd HH:mm:ss zzz yyyy\");
    Date da         


        
4条回答
  •  春和景丽
    2020-12-04 03:00

    SimpleDateFormat is Locale specific. At least the pattern E and M are locale specific, because for example "Sun" or "Sunday" will not match for Locale.GERMAN or Locale.FRENCH etc. You better specify the used Locale

    SimpleDateFormat format =  new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
    

    or use a format, which is not locale specific.

提交回复
热议问题