How to test a valid date string, assuming acceptable format is “YYYY-MM-DD”? (Y year, M month, D day)
I’ve tried DateFormat.parse(date_string) but it parses things like “2012-542-86”.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As default, the parsing is lenient, which means it uses heuristics to parse non-exact matches.
You need to turn this off using #setLenient(false) to make it reject all non-matching formats.