DateFormat: setLenient(boolean lenient) : DateFormat « java.text « Java by API






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

1.DateFormat.FULL
2.DateFormat.LONG
3.DateFormat.MEDIUM
4.DateFormat.SHORT
5.DateFormat: format(Date date)
6.DateFormat: getAvailableLocales()
7.DateFormat: getDateInstance(int style,Locale aLocale)
8.DateFormat: getDateTimeInstance(int dateStyle, int timeStyle)
9.DateFormat: getTimeInstance(int style,Locale aLocale)
10.DateFormat: parse(String dateString)