Specify whether or not date/time parsing is to be lenient. With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match this object’s format. With strict parsing, inputs must match this object’s format.
This method is equivalent to the following call.

1

2

getCalendar().setLenient(lenient)

This leniency value is overwritten by a call to setCalendar().

If the purpose of above code is to validate the date, setting the lenient field to false

at com.espressoprogrammer.samples.parser.date.LenientDateParser.main(LenientDateParser.java:13)

at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

It’s very easy to miss this kind of problems especially if a code like this is hidden in some useful methods somewhere in a common project. The solution to avoid these issues is simple but often overlooked. All we need is to add unit tests and even if we miss some detail from api, a failed test will force us to read it again.