Here you can find the source of formatDate(String format)
public static String formatDate(String format)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.*; public class Main { static String DEFAULT_FOMRAT = "MMddHHmmss"; static Map<String, SimpleDateFormat> sdfMap = new TreeMap<String, SimpleDateFormat>(); public static String formatDate(String format, Date date) { if (sdfMap.get(format) == null) { sdfMap.put(format, new SimpleDateFormat(format)); }/* w w w . j a v a 2 s. c o m*/ return sdfMap.get(format).format(date); } public static String formatDate(String format) { return formatDate(format, new Date()); } public static String formatDate() { return formatDate(DEFAULT_FOMRAT, new Date()); } }