Java Date Value Check isValidPattern(String dateString, String pattern)

Here you can find the source of isValidPattern(String dateString, String pattern)

Description

is Valid Pattern

License

Open Source License

Declaration

public static Boolean isValidPattern(String dateString, String pattern) 

Method Source Code


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

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static Boolean isValidPattern(String dateString, String pattern) {
        return parse(dateString, pattern) != null;
    }//from   w  w  w  .  ja  v  a  2 s. c om

    public static Date parse(String dateString, String pattern) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        try {
            return simpleDateFormat.parse(dateString);
        } catch (ParseException e) {
        }
        return null;
    }
}

Related

  1. isValidDatePatterns(String dateStr, String patterns)
  2. isValidDateStr(String date, String format)
  3. isValidGameDate(String gameDate)
  4. isValidLongDateFormat(String strDate)
  5. isValidObjectModelDate(String aDate)