Given the following String and formatter settings:
final SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
final String date = "Mon Jan 25 16:33:06 CET 2016";
pojo.setTimestamp(formatter.parse(date));
I get an exception and do not understand what I should do to resolve it.
I suspect the problem is with the locale used in the SimpleDateFormat
. By default, SimpleDateFormat
takes the default locale of the system... so if you run this code in France, "Mon" won't be recognized as a day-of-week abbreviation, for example.
The simplest fix for this is just to call the SimpleDateFormat
constructor which specifies a locale:
SimpleDateFormat formatter =
new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
See more on this question at Stackoverflow