Java DateFormat.setLenient(boolean lenient)
Syntax
DateFormat.setLenient(boolean lenient) has the following syntax.
public void setLenient(boolean lenient)
Example
In the following code shows how to use DateFormat.setLenient(boolean lenient) method.
/*from w w w .j ava2 s .co m*/
import java.text.DateFormat;
public class Main {
public static boolean isValidDateStr(String date) throws Exception {
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
df.setLenient(false);
df.parse(date);
return true;
}
public static void main(String[] args) throws Exception{
System.out.println(isValidDateStr("1900-13-12"));
}
}
The code above generates the following result.