Validating a date in java

Rated 4.76/5 based on 892 customer reviews

“333/2/2008”, “29/02/200a” – day is invalid, year is invalid 7. “29/a/2008”, “a/02/2008” – month is invalid, day is invalid 6.

“32/1/2010” , “32/01/2020” – day is out of range [1-31] 2.

(I care less about whitespace and formatting.) /** * Tests whether the date input represents * a real date in mm/dd/YYYY format that is after the current date.

* Useful for testing send dates and expiration dates.

You catch anything that is a fails or if the year is non-positive.

If the year is between 0 and 100, it assumes that it is abbreviated and asks for more digits.

Leave a Reply