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

StringDateToStringByformat2(Date date)
Date To String Byformat
return format2.format(date);
StringdateToStringFecha(Date fecha)
Convierte un objeto de tipo Date a una hilera de caracteres con formato dd/MM/yyyy
SimpleDateFormat formateador = new SimpleDateFormat("dd/MM/yyyy");
return formateador.format(fecha);
StringdateToStringFormat(Date dt, String format)
date To String Format
SimpleDateFormat fmt = new SimpleDateFormat(format);
String dtStr = "";
if (dt != null) {
    dtStr = fmt.format(dt).toString();
return dtStr;
StringdateToStringShort(Date date)
date To String Short
if (date == null)
    return "";
return FormatDate(date, "yyyy-MM-dd");
StringdateToStringTemporalCoverage(Date date)
date To String Temporal Coverage
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
    return sdf.format(date);
} catch (NullPointerException ex) {
    return "";
StringdateToStringVerbose(Date date)
date To String Verbose
if (date == null) {
    return null;
return dateFormatter(false).format(date);
StringdateToStringWithFormat(Date dateToString, String dateFormat)
date To String With Format
if (dateToString != null) {
    DateFormat simpleDateFormat = new SimpleDateFormat(dateFormat);
    return simpleDateFormat.format(dateToString);
} else {
    return null;
StringdateToStringWithPattern(Date date, String pattern)
date To String With Pattern
try {
    SimpleDateFormat sdf = new SimpleDateFormat(pattern);
    return sdf.format(date);
} catch (Exception e) {
    SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
    return sdf.format(date);
StringdateToStringWithPattern(Date date, String pattern)
return time value of specified date
try {
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
    return simpleDateFormat.format(date);
} catch (Exception e) {
    return "";
StringdateToStringWithTime(Date date)
date To String With Time
return dateToString(date, DATETIME_PATTERN);