Java Utililty Methods Date Format

List of utility methods to do Date Format

Description

The list of methods to do Date Format are organized into topic(s).

Method

StringformatDate(Date date)
format Date
if (date == null) {
    return "";
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(date);
StringformatDate(Date date)
format Date
return formatDate(date, DEFAULTFORMAT);
StringformatDate(Date date)
Formats a date and time as (for example) "02/06/02 10:32 AM".
return dateFormatter1.format(date);
StringformatDate(Date date)
Format a date as returned by the Apache HTTP Client date formatter into an application specific format.
DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.US);
try {
    SimpleDateFormat simpleFormatter = (SimpleDateFormat) formatter;
    simpleFormatter.applyPattern("EEE, d MMM yyyy kk:mm:ss z");
    String result = simpleFormatter.format(date);
    return result;
} catch (Exception e) {
return null;
StringformatDate(Date date)
format Date
Preconditions.checkNotNull(date, "date must not be null");
String formattedDate = new SimpleDateFormat(TIMESTAMP_FORMAT).format(date);
StringBuffer dateFormatBuilder = new StringBuffer("TO_DATE('");
dateFormatBuilder.append(formattedDate).append("', 'yyyy-MM-dd HH:mm:ss z')");
return dateFormatBuilder.toString();
StringformatDate(Date date)
Format date with default pattern yyyy-MM-dd
return formatDate(date, "yyyy-MM-dd");
StringformatDate(Date date)
format Date
return format(date, "yyyy-MM-dd");
StringformatDate(Date date)
Converts the given Date instance to string.
return (new SimpleDateFormat(DATE_FORMAT)).format(date);
StringformatDate(Date date)
format Date
if (date == null) {
    return NOT_DEFINED_DATE;
return dateDF.format(date.getTime());
StringformatDate(Date date)
format Date
return DATE_FORMAT.get().format(date);