DateFormat: setLenient(boolean lenient) : DateFormat « java.text « Java by API
- Java by API
- java.text
- DateFormat
DateFormat: setLenient(boolean lenient)
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"));
}
}
Related examples in the same category