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 d)
to Date
return toDate(d, false);
DatetoDate(String date)
A method that could convert Date object to String default format -> (yyyy-MM-dd)
return toDate(date, false);
DatetoDate(String date)
to Date
return toDate(date, "00:00.00.000");
DatetoDate(String date)
Returns a Java representation of a Facebook date string.
if (date == null)
    return null;
try {
    return new Date(Long.parseLong(date) * 1000);
} catch (NumberFormatException e) {
try {
    return new SimpleDateFormat(FACEBOOK_DATE_FORMAT).parse(date);
...
DatetoDate(String date)
to Date
DateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault());
try {
    return format.parse(date);
} catch (ParseException ex) {
    return null;
DatetoDate(String date)
to Date
Date d = null;
try {
    d = _data.parse(date);
} catch (Exception e) {
return d;
DatetoDate(String date)
to Date
if (date == null)
    return null;
try {
    return df.parse(date);
} catch (ParseException e1) {
    return null;
DatetoDate(String date)
to Date
try {
    return YYYY_DD_MM.parse(date);
} catch (ParseException e) {
    try {
        return YYYYDDMM.parse(date);
    } catch (ParseException e1) {
        return null;
DatetoDate(String date, String dateFormat)
Convert string date to Date object.
return new SimpleDateFormat(dateFormat).parse(date);
DatetoDate(String date, String format)
to Date
try {
    SimpleDateFormat sdf = new SimpleDateFormat(format);
    return sdf.parse(date);
} catch (ParseException pe) {
    throw new RuntimeException(pe);