Java Date Format formatDate(Date date)

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

Description

Formats a date.

License

Open Source License

Parameter

Parameter Description
date The date.

Return

The formatted String.

Declaration

public static String formatDate(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DateFormat;
import java.text.NumberFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

import java.util.Locale;

public class Main {
    /**//www  .  ja  v  a2s. c  o  m
     * A date format.
     */
    private static DateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH-mm");

    /**
     * Formats a date.
     * 
     * @param date
     *            The date.
     * @return The formatted <i>String</i>.
     */
    public static String formatDate(Date date) {
        return df.format(date);
    }

    /**
     * Formats a double.
     * 
     * @param d
     *            A double.
     * @return The formatted <i>String</i>.
     */
    public static String format(double d) {
        NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH);
        nf.setMinimumFractionDigits(6);
        nf.setMaximumFractionDigits(6);
        return nf.format(d);
    }
}

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)