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

DateFormattoDateFormat(Integer grain, TimeZone timeZone, String dateFormatArg)
to Date Format
if (dateFormatArg != null) {
    DateFormat result = new SimpleDateFormat(dateFormatArg);
    if (timeZone != null) {
        result.setTimeZone(timeZone);
    return result;
} else {
    return dateFormat(grain, timeZone);
...
DatetoDateFormat(String date)
Formats an xsd:dateTime to a JAVA object data
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss.SSS'Z'");
return sdf.parse(date);
DateFormattoDateFormat(String dateFormat, TimeZone tz, Locale locale)
Returns an initialized DateFormat object.
DateFormat df = null;
if (dateFormat == null) {
    df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
} else {
    df = new SimpleDateFormat(dateFormat);
df.setTimeZone(tz);
return df;
...
StringtoDateOracle(Date d, String format, String hqlFormat)
to Date Oracle
StringBuffer bf = new StringBuffer();
bf.append("to_date('");
bf.append(dateFormat(d, format));
bf.append("','");
bf.append(hqlFormat);
bf.append("')");
return bf.toString();
Date[]toDates(DateFormat format, String[] values)
to Dates
return toDates(format, values, null);
StringtoDateString(Calendar cal)
to Date String
if (cal != null) {
    return ibmDateFormat.format(cal.getTime());
return null;
StringtoDateString(Date date)
to Date String
if (date == null) {
    return "";
return new SimpleDateFormat(Format_Date).format(date);
StringtoDateString(Date date)
to Date String
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+8"));
return dateFormat.format(date);
StringtoDateString(Date date)
to Date String
return new SimpleDateFormat("yyyy-MM-dd HH:mm").format(date);
StringtoDateString(Date date, String format)
to Date String
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
return dateFormat.format(date);