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(DEFAULT_DATE_FORMAT).format(date);
StringformatDate(Date date)
Returns a localized short/medium date time string.
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM);
if (dateFormat instanceof SimpleDateFormat) {
    SimpleDateFormat sdf = (SimpleDateFormat) dateFormat;
    sdf.applyPattern(sdf.toPattern().replaceAll("y+", "yyyy").concat(" z"));
return dateFormat.format(date);
StringformatDate(Date date)
format Date
if (date == null || date.getTime() == 0) {
    return null;
return ISO8601_FORMAT_OUT.format(date);
StringformatDate(Date date)
format date to the style yyyy-MM-dd HH:mm:ss
return dateTimeToStr(date, DATE_TIME_FORMAT_YYYY_MM_DD_HH_MI_SS);
StringformatDate(Date date)
Formats a date for sending to the Ribbit Rest Server
SimpleDateFormat formatter = new SimpleDateFormat(XML_DATE_FORMAT);
return formatter.format(date);
StringformatDate(Date date)
format Date
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String strDate = formatter.format(date);
return strDate;
StringformatDate(Date date)
format Date
return format(date, "yyyy-MM-dd");
StringformatDate(Date date)
Formats a date into yyyy-MM-dd'T'HH:mm:ss.SSSZ, for example 2008-02-13T18:54:29.147-03:00
String d = dateFormatMil.format(date);
d = d.substring(0, d.length() - 2) + ":" + d.substring(d.length() - 2);
return d;
StringformatDate(Date date)
format Date
return date != null ? createDateFormat().format(date) : null;
StringformatDate(Date date)
format Date
return THREAD_LOCAL_FORMAT.get().format(date);