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

StringparseDate(Date date, String format)
parse Date
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
StringparseDate(Date date, String pattern)
parse Date
if (date == null) {
    return null;
try {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    return sdf.format(date);
} catch (Exception ex) {
    ex.printStackTrace();
...
DateparseDate(DateFormat df, String dateStr)
parse date as ET or UTC
Date date = null;
if (dateStr != null && dateStr.length() > 0) {
    try {
        if (dateStr.contains("UTC")) {
            date = df.parse(dateStr);
        } else if (dateStr.contains("ET")) {
            date = df.parse(dateStr.replace("ET", "EST"));
            if (ET.inDaylightTime(date)) {
...
DateparseDate(DateFormat f, String date)
Parse date with formatter.
try {
    return f.parse(date);
} catch (ParseException e) {
    throw new RuntimeException(e);
StringparseDate(final Date date)
parse Date
String dateStr = null;
if (date != null) {
    final DateFormat time = DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.ENGLISH);
    final DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.ENGLISH);
    dateStr = time.format(date) + ", " + df.format(date);
return dateStr;
DateparseDate(final String date)
parse Date
return DATE_FORMAT.parse(date);
DateparseDate(final String date)
parse Date
return dateFormat.parse(date);
longparseDate(final String date)
Parses a string in the format yyyy-MM-ddTHH:mm:ssZ into a long timestamp.
return DATE_FORMAT.get().parse(date).getTime() / 1000;
DateparseDate(final String date)
parse Date
if (date.startsWith("PT")) {
    return parseDuration(date);
final SimpleDateFormat dateFormat = new SimpleDateFormat();
dateFormat.setLenient(false);
for (int i = 0; i < DATEFORMATS.length; i++) {
    try {
        final String dateformat = DATEFORMATS[i];
...
DateparseDate(final String date, final List patterns)
Tries to convert the given String to a Date.
for (String pattern : patterns) {
    final SimpleDateFormat formatter = new SimpleDateFormat(pattern);
    try {
        final Date result = formatter.parse(date);
        return result;
    } catch (final ParseException e) {
return null;