Here you can find the source of formatDateTime(Date date)
public static String formatDateTime(Date date)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; public class Main { static Map<String, SimpleDateFormat> dateFormats = new HashMap<String, SimpleDateFormat>(); static DecimalFormat df = new DecimalFormat("0.00"); public static String formatDateTime(Date date) { return formatDate(date, "EEE, d MMM yyyy HH:mm:ss"); }/*w ww . j av a 2 s. c o m*/ /** * Format a date with a given format. Formats are cached to prevent excessive use of * DateFormat. * @param date * @param format * @return */ public static String formatDate(Date date, String format) { if (!dateFormats.containsKey(format)) { dateFormats.put(format, new SimpleDateFormat(format)); } if (date == null) { return ""; } return dateFormats.get(format).format(date); } public static String format(Double d) { return df.format(d); } public static String format(Float f) { return df.format(f); } }