Java Date Value Check isDate(String strDate, String pattern)

Here you can find the source of isDate(String strDate, String pattern)

Description

is Date

License

Apache License

Declaration

public static final boolean isDate(String strDate, String pattern) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.ParsePosition;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final boolean isDate(String strDate, String pattern) {
        SimpleDateFormat formatter = new SimpleDateFormat(pattern);
        formatter.setLenient(false);/*from  ww w  . ja  va2s . co  m*/
        ParsePosition pos = new ParsePosition(0);
        try {
            Date d = formatter.parse(strDate, pos);
            return true;
        } catch (Exception e) {
            return false;
        }
    }
}

Related

  1. IsDate(String str)
  2. isDate(String str, String format)
  3. isDate(String str, String pattern)
  4. isDate(String strDate, SimpleDateFormat sdf)
  5. isDate(String strDate, String pattern)
  6. isDate(String strDate, String pattern)
  7. isDate(String text, String pattern)
  8. isDate(String val, SimpleDateFormat formatter)
  9. isDate(String value, Locale locale)