Unable to parse date from string in Java (java.text.ParseException)

I am trying to parse a string describing a date (in French):

String dateAParser="dim 6 janv 2013 07:40:00"; SimpleDateFormat parseur = new SimpleDateFormat("EEE dd MMMM yyyy HH:mm:ss", Locale.FRENCH); try{ Date dateAllerDepart= new Date(); dateAllerDepart=parseur.parse(dateAParser); System.out.println(dateAllerDepart); }catch(Exception e){e.printStackTrace();} 

This gives me the following errors:

 java.text.ParseException: Unparseable date: "dim 6 janv 2013 07:40:00" at java.text.DateFormat.parse(DateFormat.java:357) at TestAvecJsoup.main(TestAvecJsoup.java:109) 

I think my SimpleDateFormat object is fine, and I searched and tried a lot of things to solve this problem, so I hope you will give some tips on how to solve it. Thanks in advance.

+4
source share
3 answers

Two minor changes, adding periods after abbreviations and using 3 M instead of 4:

  final String dateAParser = "dim. 6 janv. 2013 07:40:00"; final SimpleDateFormat parseur = new SimpleDateFormat("EEE dd MMM yyyy HH:mm:ss", Locale.FRENCH); 
+5
source

Try the following:

  Date d = Date.valueOf(dateString); 

or

  Date d= Date.parse(string); 
0
source

The first part of the date is String "dim" and month, it seems like a problem here, are you sure this is the correct value?

This works great.

  String dateAParser="06 2013 07:40:00 AM"; SimpleDateFormat parseur = new SimpleDateFormat("dd yyyy hh:mm:ss a", Locale.FRENCH); 
0
source

All Articles