Java Utililty Methods String to Date

List of utility methods to do String to Date

Description

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

Method

DatetoDate(String pattern, String date)
to Date
try {
    return new SimpleDateFormat(pattern).parse(date);
} catch (ParseException e) {
    e.printStackTrace();
return null;
DatetoDate(String pString, String pFormat)
Converts the string to a date, using the given format.
return toDate(pString, new SimpleDateFormat(pFormat));
DatetoDate(String s)
returns the date that correspond to the given text DD-MM-YYYY
SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy");
df.setLenient(false);
Date d = null;
try {
    d = df.parse(s);
} catch (Exception e) {
return d;
...
DatetoDate(String s)
to Date
return sdf1.parse(s);
DatetoDate(String s, String format)
to Date
if (isEmpty(s)) {
    return null;
DateFormat df = new SimpleDateFormat(format);
try {
    return df.parse(s);
} catch (ParseException e) {
    e.printStackTrace();
...
DatetoDate(String sdate, SimpleDateFormat dateFormater)
to Date
try {
    return dateFormater.parse(sdate);
} catch (ParseException e) {
    return null;
DatetoDate(String sDate, String sFmt)
to Date
Date dt = null;
try {
    dt = new SimpleDateFormat(sFmt).parse(sDate);
} catch (ParseException e) {
    return dt;
return dt;
DatetoDate(String str)
to Date
SimpleDateFormat format;
format = getDefaultDateFormat();
try {
    return format.parse(str);
} catch (ParseException e) {
    return null;
DatetoDate(String str)
to Date
DateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
return format.parse(str);
DatetoDate(String str)
to Date
Date date = DateFormat.getDateInstance().parse(str);
return date;