Java Utililty Methods Date to String

List of utility methods to do Date to String

Description

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

Method

Stringdate2Str(Date aDate)
date Str
SimpleDateFormat df = null;
String returnValue = "";
if (aDate != null) {
    df = new SimpleDateFormat("yyyy-MM-dd");
    returnValue = df.format(aDate);
return (returnValue);
Stringdate2Str(Date date)
date Str
String format = "yyyy-MM-dd HH:mm:ss";
return date2Str(date, format);
StringDate2Str(Date date)
Date Str
String str = null;
try {
    str = new SimpleDateFormat("yyyy/MM/dd,HH:mm:ss").format(date);
} catch (Exception e) {
return str;
Stringdate2Str(Date date)
date Str
try {
    return dateFormat.format(date);
} catch (Exception ex) {
    return "";
Stringdate2Str(Date date, String dateFormat)
date Str
if (date == null) {
    return null;
SimpleDateFormat df = new SimpleDateFormat(dateFormat);
return df.format(date);
Stringdate2Str(Date date, String format)
date Str
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(date);
Stringdate2Str(Date date, String format)
convert a date to a format string default format:yyyy-MM-dd HH:mm:ss
if (date != null)
    return long2Datestr(date.getTime(), format);
else
    return long2Datestr(new Date().getTime(), format);
Stringdate2Str(Date date, String partten)
date Str
String result = null;
df.applyPattern(partten);
result = df.format(date);
return result;
Stringdate2Str(Date date, String pattern)
date Str
if (null == date) {
    return null;
if (null == pattern) {
    pattern = DEFAULT_DATE_FORMAT;
SimpleDateFormat format = new SimpleDateFormat();
format.applyPattern(pattern);
...
Stringdate2Str(Date value)
date Str
if (value == null)
    return null;
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(value);