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 dateString, String dateFormatPattern)
is Valid Date
Date validDate = null;
synchronized (dateFormat) {
    try {
        dateFormat.applyPattern(dateFormatPattern);
        dateFormat.setLenient(false);
        validDate = dateFormat.parse(dateString);
    } catch (ParseException e) {
return validDate != null;
booleanisValidDate(String dateString, String format)
Returns true if the specified String represents a valid date
boolean ret = false;
SimpleDateFormat fmt = new SimpleDateFormat(format);
try {
    fmt.parse(dateString);
    ret = true;
} catch (ParseException ex) {
return ret;
...
booleanisValidDate(String dt)
is Valid Date
Boolean result = true;
String dateformat = "yyyyMMdd";
try {
    SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
    sdf.setLenient(false);
    sdf.parse(dt);
} catch (ParseException e) {
    result = false;
...
booleanisValidDate(String inDate)
is Valid Date
Date date = null;
for (SimpleDateFormat format : dateFormats) {
    format.setLenient(false);
    try {
        if (inDate.length() < 12 && format.toPattern().length() < 12) {
            date = format.parse(inDate.trim());
        } else if (inDate.length() > 12 && format.toPattern().length() > 12) {
            date = format.parse(inDate.trim());
...
booleanisValidDate(String psDt)
is Valid Date
Integer dia;
Integer mes;
Integer ano;
Date dataConv;
Date dataLimiteInf;
Date dataLimiteSup;
String a = psDt.trim();
if (a.length() != 10)
...
booleanisValidDate(String s)
is Valid Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
sdf.setLenient(false);
try {
    java.util.Date date = sdf.parse(s);
    if (date.after(new java.util.Date())) {
        return false; 
} catch (ParseException fe) {
...
booleanisValidDate(String src, String format)
is Valid Date
SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.UK);
@SuppressWarnings("unused")
Date date = null;
try {
    date = formatter.parse(src);
} catch (ParseException e) {
    return false;
return true;
booleanisValidDate(String value)
is Valid Date
try {
    SimpleDateFormat shortFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT,
            internalLocale);
    shortFormat.setLenient(false);
    shortFormat.parse(value);
    return true;
catch (java.text.ParseException e) {
...
booleanisValidDateFormat(String startDate)
Returns true if the provided GTFS-rt start_date is in YYYYMMDD format, false if it is not
mDateFormat.setLenient(false);
if (startDate.length() != 8) {
    return false;
try {
    mDateFormat.parse(startDate);
} catch (ParseException e) {
    return false;
...
booleanisValidDateFormat(String strDate, String dataFormat)
is Valid Date Format
DateFormat df = getNewDateFormat(dataFormat);
try {
    df.parse(strDate);
} catch (ParseException e) {
    return false;
return true;