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(final Date date, final String dateFormat)
date Str
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
try {
    return sdf.format(date);
} catch (Exception e) {
    return null;
Stringdate2Str(SimpleDateFormat date_sdf)
date Str
Date date = getDate();
if (null == date) {
    return null;
return date_sdf.format(date);
Stringdate2string(Date _aDate)
datestring
final String m_dateFormatXAdES = "yyyy-MM-dd'T'HH:mm:ss'Z'";
SimpleDateFormat f = new SimpleDateFormat(m_dateFormatXAdES);
f.setTimeZone(TimeZone.getTimeZone("GMT+00:00"));
String dateStr = f.format(_aDate);
return dateStr;
Stringdate2string(Date date)
datestring
SimpleDateFormat df = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", Locale.ENGLISH);
String sendtime = df.format(date);
return sendtime;
Stringdate2string(Date date)
datestring
return date2string(date, "yyyy-MM-dd HH:mm:ss");
Stringdate2String(Date date)
date String
SimpleDateFormat formatter = new SimpleDateFormat(DEFAULT_DATE_PATTERN);
formatter.setTimeZone(TimeZone.getDefault());
return formatter.format(date);
Stringdate2String(Date date)
date String
return date2String(date, "yyyy-MM-dd HH:mm");
Stringdate2String(Date date)
This method convert date to format string
if (date == null) {
    return "";
return SDFDATE.format(date);
Stringdate2String(Date date)
date String
return date2String(date, "-");
Stringdate2String(Date date)
date String
return date2String(date, "yyyy-MM-dd HH:mm:ss.SSS");