Java Date Format formatDate(Date date)

Here you can find the source of formatDate(Date date)

Description

Convenience method for converting Date to a string representation with minimal overhead.

License

Open Source License

Parameter

Parameter Description
date date

Return

formatted date string

Declaration

public static String formatDate(Date date) 

Method Source Code

//package com.java2s;
import java.text.DateFormat;
import java.text.Format;

import java.util.Date;

public class Main {
    private static ThreadLocal<Format> DATE_FORMAT = new ThreadLocal<Format>() {
        @Override/*from   w  w w  .  j  a v  a 2 s  .c om*/
        protected Format initialValue() {
            return DateFormat.getDateInstance();
        }
    };

    /**
     * Convenience method for converting {@link Date} to a string
     * representation with minimal overhead.
     * 
     * <p>
     * Intended for use in KRAD SpEL expressions, for example:
     * </p>
     * 
     * <pre>
     * @{T(org.kuali.ole.krad.OleComponentUtils).formatDate(aDate)}
     * </pre>
     * 
     * @param date date
     * @return formatted date string
     */
    public static String formatDate(Date date) {
        return date == null ? "" : DATE_FORMAT.get().format(date);
    }
}

Related

  1. formatDate(Date date)
  2. formatDate(Date date)
  3. formatDate(Date date)
  4. formatDate(Date date)
  5. formatDate(Date date)
  6. formatDate(Date date)
  7. formatDate(Date date)
  8. formatDate(Date date)
  9. formatDate(Date date)