Java Date Value Check isValidDateStr(String date, String format)

Here you can find the source of isValidDateStr(String date, String format)

Description

is Valid Date Str

License

Open Source License

Declaration

public static boolean isValidDateStr(String date, String format) 

Method Source Code


//package com.java2s;

import java.text.SimpleDateFormat;

public class Main {
    public static boolean isValidDateStr(String date, String format) {

        try {/*from w w w. j  a  va2 s  .  c o m*/
            if (date.length() != format.length()) {
                return false;
            }
            SimpleDateFormat sdf = new SimpleDateFormat(format);
            sdf.setLenient(false);
            sdf.parse(date);
        } catch (Exception e) {
            return false;
        }

        return true;
    }
}

Related

  1. isValidDateFormat(String startDate)
  2. isValidDateFormat(String strDate, String dataFormat)
  3. isValidDateInternal(String date, String dateFormat)
  4. isValidDatePattern(String pattern)
  5. isValidDatePatterns(String dateStr, String patterns)
  6. isValidGameDate(String gameDate)
  7. isValidLongDateFormat(String strDate)
  8. isValidObjectModelDate(String aDate)
  9. isValidPattern(String dateString, String pattern)