I have a string in this format dd-NameOfMonth-yy
example : String str="12-nov-12"
And i would like to convert it to a Date
.
I tried the following code but i got the error :
java.text.ParseException: Unparseable date: "14-Sep-11"
DateFormat formatter = null;
Date convertedDate = null;
String ddMMMyy = "14-Sep-11";
formatter = new SimpleDateFormat("dd-MMM-yy");
convertedDate = (Date) formatter.parse(ddMMMyy);
System.out.println("Date from dd-MMM-yy String in Java : " + convertedDate);