Here you can find the source of date2String(Date date, DateFormat dateFormat)
public synchronized static String date2String(Date date, DateFormat dateFormat)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); public synchronized static String date2String(Date date, DateFormat dateFormat) { if (date == null) return null; return dateFormat.format(date); }/*from w w w.j av a2 s.c o m*/ public static String date2String(Date date, String dateFormat) { if (date == null) return null; return date2String(date, new SimpleDateFormat(dateFormat)); } public static String date2String(Date date) { if (date == null) return null; return date2String(date, DEFAULT_DATE_FORMAT); } }