Link to home
Start Free TrialLog in
Avatar of ANISHKA1
ANISHKA1Flag for United States of America

asked on

How to verify date in java?

I have to verify date is valid in mm/dd/yyyy formate after submittingbutton.
how do i get  that?

Thanks
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

You need to use DateFormat class's parse method for this.
DateFormat df=DateFormat.getDateInstance();
myDate = df.parse(above date string);

If you get parse exception in the above code, then the date is not in the proper format.

Check this for more details:
http://java.sun.com/j2se/1.4.2/docs/api/java/text/DateFormat.html

ASKER CERTIFIED SOLUTION
Avatar of chaitu chaitu
chaitu chaitu
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ANISHKA1

ASKER

It is perfect.