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, String pattern)
date To String
if ((date == null) || (pattern == null)) {
    throw new IllegalArgumentException();
return new SimpleDateFormat(pattern).format(date).toString();
StringdateToString(Date date, String pattern)
date To String
if (date == null) {
    return "";
} else {
    SimpleDateFormat format = new SimpleDateFormat(pattern);
    return format.format(date);
StringdateToString(Date date, String pattern)
Date converted to a string.
return getDateFormat(pattern).format(date);
StringdateToString(Date date, String sPattern)
Convert the date to a String representation using the pattern specified.
if (date != null) {
    SimpleDateFormat fmtDateHandler = new SimpleDateFormat(sPattern);
    return fmtDateHandler.format(date);
} else {
    return "";
StringdateToString(Date date, String strFormat)
This method formats the given Java date object to a string of given format.
try {
    if (date == null)
        return "";
    String strDtFormat = strFormat.toLowerCase();
    strDtFormat = replaceString(strDtFormat, "m", "M");
    SimpleDateFormat formatter = new SimpleDateFormat(strDtFormat);
    return formatter.format(date);
} catch (Exception ex) {
...
Stringdatetostring(Date dateInst)
datetostring
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
String dtstring = formatter.format(dateInst);
return dtstring;
StringDateToString(Date Expression)
Date To String
return DateToString(Expression, defaultPattern);
StringdateToString(Date fecha)
date To String
try {
    return formatoFecha.format(fecha);
} catch (Exception e) {
    return "";
StringDateToString(Date fecha, String formato)
Date To String
if (nullToBlank(fecha).equals("")) {
    return "";
SimpleDateFormat df = new SimpleDateFormat(formato);
return df.format(fecha);
StringdateToString(Date pd_fecha)
TODO [Convierte el obeto de fecha a Strgin dando formato, esta fecha es usada para crear parte del identificador del bloque de registros que se este procesando.]
String ls_fecha = null;
try {
    SimpleDateFormat formatDateJava = new SimpleDateFormat("ddMMyyyyHH:mm:ss");
    ls_fecha = formatDateJava.format(pd_fecha);
} catch (Exception e) {
    ls_fecha = null;
return ls_fecha;
...