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

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

Description

is Date

License

Open Source License

Declaration

public static boolean isDate(String str, String pattern) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

public class Main {

    public static boolean isDate(String str, String pattern) {
        if (str == null) {
            return false;
        }//w  w  w  .  j  ava 2  s  . co m
        if (pattern == null) {
            pattern = "YYYYMMDD";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        try {
            sdf.parse(str);
        } catch (Exception e) {
            return false;
        }
        return true;
    }
}

Related

  1. isDate(String s)
  2. isDate(String str)
  3. isDate(String str)
  4. IsDate(String str)
  5. isDate(String str, String format)
  6. isDate(String strDate, SimpleDateFormat sdf)
  7. isDate(String strDate, String pattern)
  8. isDate(String strDate, String pattern)
  9. isDate(String strDate, String pattern)