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(Long date, String format)
parse Date
if (date == null) {
    return null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format, Locale.CHINA);
try {
    return simpleDateFormat.parse(date + "");
} catch (ParseException e) {
    return null;
...
DateparseDate(Map obj, String field, String format)
parse Date
String value = getString(obj, field);
if (value != null) {
    try {
        SimpleDateFormat dateFormat = new SimpleDateFormat(format);
        return dateFormat.parse(value);
    } catch (ParseException e) {
        throw new RuntimeException(e);
return null;
DateparseDate(Object o)
parse Date
synchronized (sdf) {
    sdf.setTimeZone(GMT);
    sdf.setLenient(true);
    if (o instanceof Date) {
        return (Date) o;
    } else if (o instanceof Long) {
        Long longvalue = (Long) o;
        String s = Long.toString(longvalue);
...
DateparseDate(Object str)
parse Date
if (str == null) {
    return null;
try {
    return new SimpleDateFormat(parsePatterns[0]).parse(str.toString());
} catch (ParseException e) {
    return null;
DateparseDate(Object val)
parse to date
if (val == null)
    return null;
if (val instanceof Date) {
    return (Date) val;
} else if (val instanceof Calendar) {
    return ((Calendar) val).getTime();
} else if (val instanceof Long) {
    return new Date(((Long) val).longValue());
...
DateparseDate(SimpleDateFormat parser, String str, String[] parsePatterns)
FSM - Modified the apache function to allow you to pass in a SimpleDateFormat object.
if (str == null || parsePatterns == null) {
    throw new IllegalArgumentException("Date and Patterns must not be null");
ParsePosition pos = new ParsePosition(0);
for (int i = 0; i < parsePatterns.length; i++) {
    parser.applyPattern(parsePatterns[i]);
    pos.setIndex(0);
    Date date = parser.parse(str, pos);
...
DateparseDate(String _dateString)
parse Date
SimpleDateFormat parser = new SimpleDateFormat(FORMAT);
try {
    return parser.parse(_dateString);
} catch (ParseException _e) {
    return null;
DateparseDate(String actual, DateFormat format, Pattern pattern)
parse Date
Matcher m = pattern.matcher(actual);
m.find();
try {
    return format.parse(m.group(1));
} catch (ParseException e) {
    throw new RuntimeException(e);
DateparseDate(String applyDt)
parse Date
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
return simpleDateFormat.parse(applyDt + "000000");
DateparseDate(String buildDate, SimpleDateFormat dateFormat)
parse Date
Date date;
try {
    date = dateFormat.parse(buildDate);
} catch (ParseException e) {
    System.out.println(
            "invalid date format: " + buildDate + " with formater '" + dateFormat.toPattern() + "'");
    date = new Date();
return date;