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

StringdateToStr(Date date, String format)
date To Str
String _timeZone = System.getProperty("user.timezone");
TimeZone timeZone = null;
if (_timeZone == null || "".equals(_timeZone) || "UTC".equals(_timeZone)) {
    timeZone = TimeZone.getDefault();
} else {
    timeZone = TimeZone.getTimeZone("Asia/Shanghai");
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
...
StringdateToStr(Date date, String format)
date To Str
return new SimpleDateFormat(format).format(date);
StringdateToStr(Date date, String formatstr)
date To Str
SimpleDateFormat format = new SimpleDateFormat(formatstr);
return format.format(date);
StringdateToStr(Date date, String formatType)
date To Str
return longTypeToStr(date.getTime(), formatType);
StringdateToStr(Date source)
date To Str
return dateToStr(source, "yyyy-MM-dd HH:mm:ss");
StringdatetoStr2(Date date)
dateto Str
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(FmtDateTime);
String curDate = sdf.format(date);
return curDate;
StringdateToStr3(Date date)
dateto Str
if (date == null) {
    return "";
SimpleDateFormat sdate = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return sdate.format(date);
StringdateToStrIBInput(Date date)
date To Str IB Input
try {
    return formatterIBInput.format(date);
} catch (Exception e) {
    System.out.println("DateToStrIBInput Exception :" + e + " " + date);
    return null;
StringdateToString(Date d)
date To String
if (d == null)
    return null;
return dfDate.format(d);
StringdateToString(Date d)
date To String
SimpleDateFormat sd = new SimpleDateFormat(DATE_FORMAT);
String date = sd.format(d);
return date;