Java Utililty Methods Parse Date

List of utility methods to do Parse Date

Description

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

Method

longparseDate(String dateString, String pattern)
Parse a date time String according to a supplied pattern.
return new SimpleDateFormat(pattern).parse(dateString).getTime();
DateparseDate(String dateText)
parse Date
return parseDate(dateText, null);
DateparseDate(String datetime)
parse Date
try {
    return DATE_FORMAT.parse(datetime);
} catch (ParseException e) {
    return new Date();
DateparseDate(String dateVal)
Parse string to date with default pattern yyyy-MM-dd
return parseDate(dateVal, "yyyy-MM-dd");
DateparseDate(String dateValue)
Parse a string and return a date value
return parseDate(C_DATE_PATTON_DEFAULT, dateValue);
DateparseDate(String dateValue)
Loops over all the possible date formats and tries to find the right one.
if (dateValue == null)
    return null;
Date date = null;
for (int i = 0; (date == null) && (i < formats.length); i++) {
    try {
        synchronized (formats[i]) {
            date = formats[i].parse(dateValue);
    } catch (ParseException e) {
return date;
DateparseDate(String dateValue, String strFormat)
parse Date
if (dateValue == null)
    return null;
if (strFormat == null)
    strFormat = "yyyy-MM-dd";
SimpleDateFormat dateFormat = new SimpleDateFormat(strFormat);
Date newDate = null;
try {
    newDate = dateFormat.parse(dateValue);
...
DateparseDate(String dttm)
_more_
if (dateFormats == null) {
    String[] formats = { "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd HH:mm:ss z", "yyyy-MM-dd HH:mm:ss",
            "yyyy-MM-dd HH:mm", "yyyy-MM-dd", "yyyyMMddHHmmss", "yyyyMMddHHmm", "yyyyMMddHH", "yyyyMMdd" };
    dateFormats = new ArrayList<SimpleDateFormat>();
    for (int i = 0; i < formats.length; i++) {
        SimpleDateFormat dateFormat = new java.text.SimpleDateFormat(formats[i]);
        dateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
        dateFormats.add(dateFormat);
...
DateparseDate(String dttm)
Parse the date.
String[] formats = { "yyyy-MM-dd HH:mm:ss z", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM-dd",
        "yyyyMMddHHmmss", "yyyyMMddHHmm", "yyyyMMddHH", "yyyyMMdd" };
for (int i = 0; i < formats.length; i++) {
    SimpleDateFormat dateFormat = new java.text.SimpleDateFormat(formats[i]);
    dateFormat.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
    Date date = dateFormat.parse(dttm, new ParsePosition(0));
    if (date != null) {
        return date;
...
DateparseDate(String format, String value)
parse Date
SimpleDateFormat df = getDateFormat(format);
return df.parse(value);