I am trying to convert date from one format to other format but the following code is giving me the exception: please help
public class Formatter {
public static void main(String args[]) {
String date = "12-10-2012";
try {
Date formattedDate = parseDate(date, "MM/dd/yyyy");
System.out.println(formattedDate);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static Date parseDate(String date, String format)
throws ParseException {
SimpleDateFormat formatter = new SimpleDateFormat(format);
return formatter.parse(date);
}
}