Java class to check validity of dates.