I need to valid a date entered by a user on a form. Its a free flowing text field so it can be any number of formats. So I cannot easly pick out the year, month, & day fields. So I can not set a Calander object.
I have the part that tests if the format is valid. But then I need to test to see if the date itself is valid like... 33 sept 07 is bad, 07/66/2007 is bad.
First, what format does the entered string have to have exactly - or is that not specified, and does the computer have to intelligently parse the entered text and make a Date out of it?
The second is very hard, for example what if the user enters "08/09/2007" - there is no way for the computer to know if that means 9 August or 8 September 2007.
By using DateFormat.SHORT as you did in your code, DateFormat.parse(...) will accept some things but not everything, and what the parse(...) method does and does not accept exactly isn't clearly specified in the Java API documentation.
It's easier to change the design your application: instead of one free-format text field, use separate fields for the date, month and year (and time if necessary) - that will be much easier to parse for the computer.