String dateFormat = "MM/dd/yyyy";
int dateFormatLength = dateFormat.length();
try {
if (recdt.length() != dateFormatLength)
throw new Exception();
else {
SimpleDateFormat format = new SimpleDateFormat(dateFormat);
format.setLenient(false);
Date theDate = new Date();
theDate = format.parse(recdt);
a =0;
System.out.println("valid date" +a);
}
}
catch(Exception e)
{
a = 1;
System.out.println("invalid date" +a);
if (a==1)
{
errors.add("Recdt", new ActionError("error.recdt"));
}
}
I have used this in validation. And i have date from user input in recdt
private String recdt = null;
public String getRecdt() {
return (this.recdt);
}
public void setRecdt(String recdt) {
this.recdt = recdt;
}
I am not getting what u r saying exactly as i am new to
java can you please help me or modify code somewhere Its little urgent.
Thank you for your support