Java Date Value Check isDate(String str)

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

Description

is Date

License

Open Source License

Declaration

public static boolean isDate(String str) 

Method Source Code


//package com.java2s;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Main {
    public static String DATE_FORMAT_A = "MMddyyyy";

    public static boolean isDate(String str) {
        boolean isDate = false;

        if (str == null)
            return isDate;

        str = str.replaceAll("[/-]", "");

        DateFormat df = new SimpleDateFormat(DATE_FORMAT_A);

        try {//w w w.  j  a  v  a  2  s  . c  o  m
            df.parse(str);

            isDate = true;
        } catch (ParseException ex) {
        }

        return isDate;
    }
}

Related

  1. isDate(String dttm, String format)
  2. isDate(String input)
  3. isDate(String input)
  4. isDate(String pattern, String text)
  5. isDate(String s)
  6. IsDate(String str)
  7. isDate(String str)
  8. isDate(String str, String format)
  9. isDate(String str, String pattern)