Java Date Format formatDate(Date date)

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

Description

Format the Date object to string with format "yyyy-MM-dd"

License

Apache License

Parameter

Parameter Description
date a parameter

Declaration

public static final String formatDate(Date date) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    private static final SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd");

    /**// w w  w. jav a2  s. c  om
     * Format the Date object to string with format "yyyy-MM-dd"
     * @param date
     * @return
     */
    public static final String formatDate(Date date) {
        if (date != null) {
            synchronized (SDF) {
                return SDF.format(date);
            }
        } else {
            return null;
        }
    }
}

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)