I am using “MM/dd/yyyy hh:mm a” to initialize SimpleDateFormat.setLenient option is set false.
Below are some use cases
1)input String:-01/02/2001 3:09 AM
expected:-should pass
actual:-passes
2)input String:-01/02/20016 3:09 AM
expected:-should NOT pass
actual:-passes
I don’t understand why 20016 is parsed as valid one!!!!!
I agree with Peter and mprivat, but if you really need to do this a solution could be: