Java Date Value Check isValidDateFormat(String strDate, String dataFormat)

Here you can find the source of isValidDateFormat(String strDate, String dataFormat)

Description

is Valid Date Format

License

Open Source License

Declaration

public static boolean isValidDateFormat(String strDate,
        String dataFormat) 

Method Source Code

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

public class Main {

    public static boolean isValidDateFormat(String strDate,
            String dataFormat) {/*from w w w.j a  v  a  2 s  . c  o m*/

        DateFormat df = getNewDateFormat(dataFormat);

        try {
            df.parse(strDate);
        } catch (ParseException e) {
            return false;
        }

        return true;
    }

    public static DateFormat getNewDateFormat(String pattern) {
        DateFormat df = new SimpleDateFormat(pattern);

        df.setLenient(false);
        return df;
    }
}

Related

  1. isValidDate(String psDt)
  2. isValidDate(String s)
  3. isValidDate(String src, String format)
  4. isValidDate(String value)
  5. isValidDateFormat(String startDate)
  6. isValidDateInternal(String date, String dateFormat)
  7. isValidDatePattern(String pattern)
  8. isValidDatePatterns(String dateStr, String patterns)
  9. isValidDateStr(String date, String format)