Reputation: 1059
I have a String that contains a date.
I'm trying to do so but it gives me an error.
java.text.ParseException: Unparseable date: "Fri Mar 20 20:44:49 CET 2015" (at offset 0)
at java.text.DateFormat.parse(DateFormat.java:626)
I'm trying this.
String fechaFestivo = c.getString(1);//Fri Mar 20 20:44:49 CET 2015
SimpleDateFormat format = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy");
Date date = format.parse(fechaFestivo);
Upvotes: 0
Views: 268
Reputation: 3636
Your SimpleDateFormat
is using the default locale, which may not be English. In that case, the abbreviated name of the day will not be recognized.
Make sure to use the correct locale with this constructor:
SimpleDateFormat format = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy", Locale.US);
Upvotes: 3
Reputation: 20656
Try to replace your SimpleDateFormat
for DateFormat
, something like that :
String fechaFestivo = c.getString(1); //Fri Mar 20 20:44:49 CET 2015
DateFormat format = new SimpleDateFormat("EEE MMM d HH:mm:ss zzz yyyy", Locale.ENGLISH);
Date date = format.parse(fechaFestivo);
Upvotes: 1