Hope this solves your problem
it takes in a
string validates if it is a valid date and retuns a string int the reverse order
like
you should give
java DateValidation 23-4-2001
just try out and see
import java.util.*;
import java.text.*;
public class DateValidation
{
private String datestring= null;
public DateValidation(String testStr)
{
boolean error = false;
DateFormat formatter = new SimpleDateFormat( "dd-MM-yyyy" );
formatter.setLenient(false);
Date date = null;
if (testStr.length() != 0)
{
try
{
date = formatter.parse(testStr);
SimpleDateFormat formatter1= new SimpleDateFormat ("yyyy/MM/dd");
formatter1.setLenient(false);
datestring=formatter1.format(date);
}
catch (ParseException ex)
{
System.out.println("Error parsing date");
}
}
}
public String getDateString()
{
return this.datestring;
}
public static void main(String a[])
{
DateValidation dv = new DateValidation(a[0]);
System.out.println(dv.getDateString());
}
}