import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class FormatDate {
private SimpleDateFormat inSDF = new SimpleDateFormat("mm/dd/yyyy");
private SimpleDateFormat outSDF = new SimpleDateFormat("yyyy-mm-dd");
public String formatDate(String inDate) {
String outDate = "";
if (inDate != null) {
try {
Date date = inSDF.parse(inDate);
outDate = outSDF.format(date);
} catch (ParseException ex)
System.out.println("Unable to format date: " + inDate + e.getMessage());
e.printStackTrace();
}
}
return outDate;
}
public static void main(String[] args) {
FormatDate fd = new FormatDate();
System.out.println(fd.formatDate("12/10/2013"));
}
}