So I have this String: "Tue Apr 15 00:00:00 IDT 2014" or "Apr 15 2014" after I change it by split it. And I want to convert it to this format: "yyyy-MM-dd" but when I i get this message:
java.text.ParseException: Unparseable date: "Apr 15 2014"
Here is my full code:
DateFormat or=new SimpleDateFormat("MMM d yyyy");
DateFormat tr=new SimpleDateFormat("yyyy-MM-dd");
String str="Apr 15 2014";
System.out.println(str);
//String strs[]=str.split(" ");
//String newDay=strs[1]+" "+strs[2]+" "+strs[5];
//System.out.println(newDay);
try {
Date d1=or.parse(str);
System.out.println(d1);
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Thanks to helpers :)