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

DateparseDate(String dateString)
Parses a MOCA date String (YYYYMMDDHHmmss) into a standard Java date object.
if (dateString == null)
    return null;
try {
    DateFormat tmp = (DateFormat) _dateFormat.clone();
    tmp.setLenient(false);
    return tmp.parse(dateString);
} catch (ParseException e) {
    return null;
...
DateparseDate(String dateString)
parse Date
format.setTimeZone(TimeZone.getTimeZone("GMT"));
try {
    return format.parse(dateString);
} catch (ParseException e) {
    return null;
DateparseDate(String dateString)
Utility method to create a Date class from dateString.
try {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MMM-dd");
    return sdf.parse(dateString);
} catch (ParseException pe) {
    throw new RuntimeException("Not a valid date: " + dateString + ". Must be of YYYY-MMM-DD format.");
DateparseDate(String dateString)
parse Date
for (SimpleDateFormat sdf : sdfList) {
    ParsePosition ps = new ParsePosition(0);
    Date result = sdf.parse(dateString, ps);
    if (ps.getIndex() != 0)
        return result;
System.err.println("\t\t" + dateString + " cannot be parsed!\n");
return null;
...
DateparseDate(String dateString)
parse Date
if (dateString == null) {
    return null;
SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN, Locale.US);
format.setTimeZone(GMT);
try {
    return format.parse(dateString);
} catch (ParseException ignore) {
...
DateparseDate(String dateString)
Method description
return parseDate(dateString, null);
DateparseDate(String dateString, Locale locale)
parse Date
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale);
return dateFormat.parse(dateString);
DateparseDate(String dateString, SimpleDateFormat simpleDateFormat)
parse Date
if (dateString != null && dateString.length() > 0) {
    return simpleDateFormat.parse(dateString);
} else {
    return null;
DateparseDate(String dateString, String dateFormat)
Parses the date from the given string, and the given format
Calendar cal = Calendar.getInstance();
if (dateString != null)
    return new SimpleDateFormat(dateFormat).parse(dateString);
throw new ParseException("Parse Exception manually thrown by parseDate(String, String)", 0);
DateparseDate(String dateString, String format, TimeZone zone)
Transferred in accordance with the specified format string date into a Date type.
Date date = null;
try {
    DateFormat df = getDateFormat(format);
    df.setTimeZone(zone);
    date = df.parse(dateString);
} catch (Exception e) {
    return null;
return date;