3

I'm trying to convert this String to Date:

Tue Mar 01 11:46:32 CET 2016

this is the code I have:

DateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
Date mTimeStamp = format.parse(getTimeStamp());

it throws a ParseExeption...

Christer
  • 2,746
  • 3
  • 31
  • 50

1 Answers1

5

Your format is fine - your issue may be that your default locale is not English and the day and/or month names are not valid in your default language.

This should work as expected:

DateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.ENGLISH);
Date mTimeStamp = format.parse("Tue Mar 01 11:46:32 CET 2016");
assylias
  • 321,522
  • 82
  • 660
  • 783