Here you can find the source of formatDate(Date date)
Parameter | Description |
---|---|
date | The date. |
public static String formatDate(Date date)
//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); } }