Java Date Format formatDate(Date date)

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

Description

Method description

License

Open Source License

Parameter

Parameter Description
date a parameter

Declaration

public static String formatDate(Date date) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.TimeZone;

public class Main {
    /** Field description */
    public static final String DATE_PATTERN = "yyyy-MM-dd HH-mm-ss";

    /**//from  ww  w.ja v  a  2 s  . c  om
     * Method description
     *
     *
     * @param date
     * @param tz
     *
     * @return
     */
    public static String formatDate(Date date, TimeZone tz) {
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN);

        if (tz != null) {
            sdf.setTimeZone(tz);
        }

        return sdf.format(date);
    }

    /**
     * Method description
     *
     *
     * @param date
     *
     * @return
     */
    public static String formatDate(Date date) {
        return formatDate(date, 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)