I have a problem with date checking.

In my .jsp page it has a HTML form which prompts to enter date and some other fields.

When the user enter the date into the textbox, I want to check is it a valid date or


I'm using MySQL with JSP 1.2 to do this task. According to the MySQL documentation, it

tells that it recognized the date format as follows.


As an example when the user enters the date as follows
2004-01-31 or 04-01-31 or 4-1-31

then the db saves as 2004-01-31.

When the user enters the date as 01-31-2004 or 01-32-2004 this saves as 0000-00-00.

Now, my problem is how can I check that the user entered the date as correct

format(year-month-day) and is it a valid date? I also want to check it for leap year.

Is there any method to do this? If you know to solve this, please tell me.