Here you can find the source of date2String(Date date, String format)
public static String date2String(Date date, String format)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static SimpleDateFormat simpleDateFormat = new SimpleDateFormat(); public static final String DEFAULT_DATE_FORMATE = "yyyyMMddHHmmss"; public static String date2String(Date date) { return getDate2Str(DEFAULT_DATE_FORMATE, date); }//w w w .j a v a 2 s . c o m public static String date2String(Date date, String format) { return getDate2Str(format, date); } public static synchronized String getDate2Str(String format, Date date) { simpleDateFormat.applyPattern(format); return simpleDateFormat.format(date); } }