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

java.util.DatetoDate(String strDate)
to Date
try {
    java.util.Date date = dateFormat.parse(strDate.trim(), new ParsePosition(0));
    return date;
} catch (Exception e) {
return null;
DatetoDate(String strDate)
Convert string date to Date with #FULL_DATE_FORMAT .
SimpleDateFormat fullDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
return fullDateFormat.parse(strDate);
DatetoDate(String string)
to Date
int whichFormatter = 0;
if (string.indexOf('/') > 0) {
    whichFormatter |= 0x01;
if (string.indexOf(':') > 0) {
    whichFormatter |= 0x02;
final DateFormat formatter;
...
DatetoDate(String string, String format)
to Date
DateFormat dateFormat = new SimpleDateFormat(format);
dateFormat.setLenient(true);
Date d;
try {
    d = dateFormat.parse(string);
} catch (ParseException pe) {
    throw new IllegalArgumentException(pe);
return d;
DatetoDate(String time)
to Date
if (time == null) {
    return null;
try {
    TimeZone tz = TimeZone.getTimeZone("UTC");
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSSSS");
    df.setTimeZone(tz);
    return df.parse(time);
...
DatetoDate(String time)
to Date
DateFormat df = new SimpleDateFormat(DATE_FORMAT);
return df.parse(time);
DatetoDate(String ts)
to Date
Date dts = TS_FORMAT.parse(ts);
return dts;
DatetoDate(String value)
Gets the date value of the input string value.
try {
    if (value != null) {
        SimpleDateFormat df = new SimpleDateFormat(isoDateStringFormat);
        return df.parse(value);
} catch (Exception ex) {
return null;
...
DatetoDateByFormat(String dateString, String formatStr)
to Date By Format
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(formatStr);
try {
    return sdf.parse(dateString);
} catch (ParseException ex) {
    ex.printStackTrace();
    return null;
java.util.DatetoDateByPattern(String dateTime)
to Date By Pattern
return toDateByPattern(dateTime, defaultDatePattern);