Hi,
I want to convert a date which can be of any date formats into yyyy-mm-dd format...My code is below.Could anyone please tell what is wrong in it.
String[] date_formats = {
"MM/dd/yyyy",
"dd/MM/yyyy"
,"dd-MM-yyyy",
};
String dateReceived = "13/11/2012";
for (String formatString : date_formats){
DateFormat userDate = new SimpleDateFormat(formatString);
{
DateFormat dateFormatNeeded = new SimpleDateFormat("yyyy-mm-dd");
Date date = userDate.parse(dateReceived);
String Dateconverted = dateFormatNeeded.format(date);
System.out.println(Dateconverted);
}