Java Date Value Check isDateValid(String dateString, String validFormat)

Here you can find the source of isDateValid(String dateString, String validFormat)

Description

is Date Valid

License

Apache License

Declaration

public static boolean isDateValid(String dateString, String validFormat) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {

    public static boolean isDateValid(String dateString, String validFormat) {
        DateFormat df;//from w  ww. j  av a  2  s  .  c o m
        df = (validFormat == null) ? new SimpleDateFormat("yyyy-MM-dd") : new SimpleDateFormat(validFormat);
        df.setLenient(false);
        try {
            df.parse(dateString);
            return true;
        } catch (ParseException e) {
            return false;
        }
    }
}

Related

  1. isDateInRange(Date toCheck, Date minRange, Date maxRange)
  2. IsDateOK(String date)
  3. isDateSortedAsc(List dates, String format)
  4. isDateTwo(String value)
  5. isDateValid(String date, Locale locale)
  6. isDateValid(String dateToCheck, String pattern)
  7. isDateValid(String dateToValidate)
  8. isDateValue(String inputString)
  9. isValidateData(String val)