-2

I try to convert string to date format, but the following does't work.

    String stringdate = "Fri Mar 27 17:14:27 EET 2015";
    DateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
    try {
        Date newdate = format.parse(stringdate);
    } catch (ParseException e) {
        e.printStackTrace();
    }

the output is

java.text.ParseException: Unparseable date: "Fri Mar 27 17:14:27 EET 2015"

andy007
  • 907
  • 1
  • 15
  • 41

1 Answers1

1

SimpleDateFormat is locale-sensitive, so your default locale may be the reason why the exception is thrown. Try setting the locale to US.

DateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
TNT
  • 2,900
  • 3
  • 23
  • 34