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 str, Locale locale, String... parsePatterns)

Parses a string representing a date by trying a variety of different parsers, using the default date format symbols for the given locale.

The parse will try each parse pattern in turn.

return parseDateWithLeniency(str, locale, parsePatterns, true);
DateparseDate(String str, String pattern)
parse Date
java.text.DateFormat format = new java.text.SimpleDateFormat(pattern);
Date date = null;
try {
    date = format.parse(str);
} catch (Exception e) {
return date;
DateparseDate(String str, String timezone)
parse Date
if (timezone != null) {
    ISO8601_FORMAT_IN.setTimeZone(TimeZone.getTimeZone(timezone));
if (str == null) {
    return new Date(0);
try {
    return ISO8601_FORMAT_IN.parse(str);
...
DateparseDate(String str, String[] parsePatterns)
parse Date
if (str == null || parsePatterns == null) {
    throw new IllegalArgumentException("Date and Patterns must not be null");
SimpleDateFormat parser = null;
ParsePosition pos = new ParsePosition(0);
for (int i = 0; i < parsePatterns.length; i++) {
    if (i == 0) {
        parser = new SimpleDateFormat(parsePatterns[0]);
...
DateparseDate(String str, String[] parsePatterns)

Parses a string representing a date by trying a variety of different parsers.

if (str == null || parsePatterns == null) {
    throw new IllegalArgumentException("Date and Patterns must not be null");
SimpleDateFormat parser = null;
ParsePosition pos = new ParsePosition(0);
for (int i = 0; i < parsePatterns.length; i++) {
    if (i == 0) {
        parser = new SimpleDateFormat(parsePatterns[0]);
...
DateparseDate(String strDate)
parse Date
return parseDate(strDate, getDatePattern());
DateparseDate(String strDate)
parse Date
Date date = null;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
    date = sdf.parse(strDate);
} catch (ParseException e) {
    e.printStackTrace();
    return null;
return date;
DateparseDate(String strDate)
parse Date
SimpleDateFormat sdf = new SimpleDateFormat(datePatter);
sdf.setTimeZone(TimeZone.getTimeZone(timeZoneCode));
sdf.setLenient(false);
return sdf.parse(strDate);
DateparseDate(String strDate)
parse Date
Date date = null;
try {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    date = dateFormat.parse(strDate);
    return date;
} catch (Exception pe) {
    return null;
DateparseDate(String strDate, String format)
parse Date
ParsePosition pos = new ParsePosition(0);
DateFormat df = new SimpleDateFormat(format);
Date strtodate = df.parse(strDate, pos);
return strtodate;