Java Utililty Methods Date Value Check

List of utility methods to do Date Value Check

Description

The list of methods to do Date Value Check are organized into topic(s).

Method

booleanisValidDate(String date)
is Valid Date
return isValidDateInternal(date, DATE_FORMAT);
booleanisValidDate(String date, String dateFormat)
is Valid Date
try {
    new SimpleDateFormat(dateFormat).parse(date);
    return true;
} catch (Exception e) {
    return false;
booleanisValidDate(String date, String format)
Tests the input string to ensure that a valid Date instance can be created from it according to the format provided.
if (date == null)
    return false;
try {
    parse(date, format);
} catch (java.text.ParseException e) {
    return false;
return true;
...
booleanisValidDate(String dateStr)
is Valid Date
boolean isValid = false;
if (dateStr == null || dateStr.length() <= 0) {
    return false;
String pattern = "yyyy-MM-dd";
try {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    String date = sdf.format(sdf.parse(dateStr));
...
booleanisValidDate(String dateString)
Checks whether the actual date of the given date string is valid.
try {
    parse(dateString);
    return true;
} catch (ParseException e) {
    return false;
booleanisValidDate(String dateString)
is Valid Date
try {
    dateFormat.parse(dateString);
    return true;
} catch (Exception e) {
    return false;
booleanisValidDate(String dateString, String dateFormat)
Checks whether the actual date of the given date string is valid based on the given date format pattern.
try {
    parse(dateString, dateFormat);
    return true;
} catch (ParseException e) {
    return false;
booleanisValidDate(String dateString, String dateFormat)
is Valid Date
if (dateString != null && (dateString.length() > 0)) {
    try {
        DateFormat df = new SimpleDateFormat(dateFormat);
        df.setLenient(false);
        df.parse(dateString);
        return true;
    } catch (ParseException e) {
        return false;
...
booleanisValidDate(String dateString, String dateFormat)
Checks whether the actual date of the given date string is valid based on the given date format pattern.
try {
    parse(dateString, dateFormat);
    return true;
} catch (ParseException e) {
    return false;
booleanisValidDate(String dateString, String dateFormat)
Checks whether the actual date of the given date string is valid based on the given date format pattern.
try {
    parse(dateString, dateFormat);
    return true;
} catch (ParseException e) {
    return false;