Reputation: 4919
How to parse this string?
"Mon Jul 02 13:49:16 CEST 2012"
String Date = "Mon Jul 02 13:11:38 CEST 2012";
DateFormat formatter;
Date convertedDate= new Date();
formatter = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy");
try {
convertedDate = (Date) formatter.parse(Date);
} catch (ParseException ex) {
Logger.getLogger(ItemRecTestCases.class.getName()).log(Level.SEVERE, null, ex);
}
Dont work..."java.text.ParseException: Unparseable date:
"
Upvotes: 1
Views: 203
Reputation: 382130
You need to set the locale :
formatter = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy", Locale.ENGLISH);
Or else "Mon" cannot be parsed as "monday".
Upvotes: 7
Reputation: 2423
The Locale needs to be specified:
formatter = new SimpleDateFormat("EEE MMM d HH:mm:ss z yyyy", Locale.US);
Upvotes: 6