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

StringdateToString(Date date)
Convert Date to String with MM/dd/yyyy format.
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
return sdf.format(date);
StringdateToString(Date date)
date To String
if (date == null) {
    return "NULL";
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'", Locale.getDefault());
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
String formatted = dateFormat.format(date);
return formatted;
StringdateToString(Date date)
date To String
String dateString = null;
if (date != null) {
    SimpleDateFormat sdf = new SimpleDateFormat(m_datePattern);
    sdf.setTimeZone(TimeZone.getTimeZone("Europe/Berlin"));
    dateString = sdf.format(date);
return dateString;
StringdateToString(Date date)
Converts Date type to String based on RFC3339 formatting
final TimeZone utc = TimeZone.getTimeZone("UTC");
SimpleDateFormat tformat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
tformat.setTimeZone(utc);
return tformat.format(date);
StringdateToString(Date date)
Converts the date to String
if (date == null) {
    return null;
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(date);
StringDateToString(Date date)
Convert date to string , default pattern is yyyy-MM-dd
return DateToString(date, DATE_PATTERN);
StringdateToString(Date date)
date To String
DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date today = Calendar.getInstance().getTime();
String reportDate = df.format(today);
return reportDate;
StringdateToString(Date date)
date To String
if (date == null)
    return "";
else {
    SimpleDateFormat sdFormat = new SimpleDateFormat(DEFAULT_DATE_FORMATE, Locale.getDefault());
    String str_Date = sdFormat.format(date);
    return str_Date;
StringdateToString(Date date)
date To String
if (date == null)
    return "";
return FormatDate(date, "yyyy-MM-dd HH:mm:ss");
StringdateToString(Date date, String dateFormat)
date To String
if (date == null)
    return "";
try {
    return new SimpleDateFormat(dateFormat).format(date);
} catch (Exception e) {
    e.printStackTrace();
    return "";