Here you can find the source of date2String2(Date date)
public static String date2String2(Date date)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; public class Main { private static final String dateFormat7 = "HHmm"; private static final Map<String, DateFormat> DFS = new HashMap<String, DateFormat>(); public static String date2String2(Date date) { SimpleDateFormat formatter = new SimpleDateFormat(dateFormat7); String dateString = formatter.format(date); return dateString; }// w w w .jav a 2s . c o m public static String format(Date date, String pattern) { if (date == null) { return null; } return getFormat(pattern).format(date); } public static DateFormat getFormat(String pattern) { DateFormat format = DFS.get(pattern); if (format == null) { format = new SimpleDateFormat(pattern); DFS.put(pattern, format); } return format; } }