Java Utililty Methods Date Parse

List of utility methods to do Date Parse

Description

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

Method

DateconvertStringToDate(String str_date)
Convert string to date.
if (str_date != null && str_date.length() == 19)
    return convertStringToDateWithTime(str_date);
Date dt = null;
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
try {
    if (str_date != null) {
        dt = (Date) formatter.parse(str_date);
} catch (ParseException e) {
    e.printStackTrace();
return dt;
DateconvertStringToDate(String strDate)
This method converts a String to a date using the datePattern
Date aDate = null;
try {
    aDate = convertStringToDate(datePattern, strDate);
} catch (ParseException pe) {
    pe.printStackTrace();
    return null;
return aDate;
...
DateconvertStringToDate(String strDate, String parseFormat)
convert String To Date
try {
    return new SimpleDateFormat(parseFormat).parse(strDate);
} catch (Exception e) {
    e.printStackTrace();
    return null;
java.util.DateconvertStringToDate(String stringDate, String pattern)
convert String To Date
java.util.Date date = null;
try {
    SimpleDateFormat formatter = new SimpleDateFormat(pattern);
    formatter.setLenient(true);
    date = formatter.parse(stringDate);
} catch (Exception e) {
    date = new java.util.Date();
return date;
longconvertStringToDate(String value)
Converts the string value to date.
if (value == null) {
    return -1L;
try {
    return DATE_FORMAT.parse(value).getTime();
} catch (ParseException ignore) {
throw new IllegalArgumentException(value);
...
DateconvertStringToDateTimeNotException(String date)
convert String To Date Time Not Exception
String pattern = "dd/MM/yyyy HH:mm:ss";
try {
    return convertStringToTime(date, pattern);
} catch (Exception e) {
    return null;
DateconvertStringToDateWithRFC1123(final String dateTime)
convert String To Date With RFC
try {
    return RFC1123_DATE_FORMAT.parse(dateTime);
} catch (final ParseException ex) {
return DATE_MIN;
DateconvertStringToTime(String date, String pattern)
convert String To Time
if (date == null || "".equals(date.trim())) {
    return null;
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, Locale.ENGLISH);
return dateFormat.parse(date);
DateconvertStringToTime(String date, String pattern)
convert String To Time
SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
try {
    return dateFormat.parse(date);
} catch (ParseException e) {
    System.out.println("Date ParseException, string value:" + date);
    throw e;
DateconvertStrToDate(String dateStr, String dateFormat)
convert Str To Date
if (dateStr == null || dateStr.equals("")) {
    return null;
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
try {
    return sdf.parse(dateStr);
} catch (Exception e) {
    throw new RuntimeException("DateUtil.convertStrToDate():" + e.getMessage());
...