Unparseable date: "20/02/2014"
I have date "20/02/2014" in String format and want to change it's format to "MMMM dd,yyyy" but it gives error.
Here is the code:
try {
SimpleDateFormat df = new SimpleDateFormat("MMMM dd,yyyy");
Date date = df.parse("20/02/2014");
System.out.println(date);
} catch (ParseException e) {
e.printStackTrace();
} catch (java.text.ParseException e) {
e.printStackTrace();
}
try this code :
try { String str = "20/02/2014"; SimpleDateFormat sdf1 = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("MMMM dd,yyyy"); System.out.println("Formatted Date : "+sdf2.format(sdf1.parse(str))); } catch (Exception e) { e.printStackTrace(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With