The code is as mentioned below:
public static void main(String[] args){
Date date = new Date();
DateFormat dateFormat= new SimpleDateFormat("dd-MMM-yyy");
try{
Date formattedDate = dateFormat.parse(date.toString());
System.out.println(formattedDate.toString());
}catch(ParseException parseEx){
parseEx.printStackTrace();
}
}
In code above, dateFormat.parse(date.toString()) is throwing unparseable date exception: Unparseable date: "Mon Jan 28 18:53:24 IST 2013
I am not able to figure out the reason for it.