Here you can find the source of dateTime2String(Date dateTime, DateFormat dateFormat)
public synchronized static String dateTime2String(Date dateTime, 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 static final DateFormat DEFAULT_DATETIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public synchronized static String dateTime2String(Date dateTime, DateFormat dateFormat) { if (dateTime == null) return null; return dateFormat.format(dateTime); }/*from w w w. ja va 2 s . c o m*/ public static String dateTime2String(Date dateTime, String dateFormat) { if (dateTime == null) return null; return date2String(dateTime, dateFormat); } public static String dateTime2String(Date dateTime) { if (dateTime == null) return null; return date2String(dateTime, DEFAULT_DATETIME_FORMAT); } public synchronized static String date2String(Date date, DateFormat dateFormat) { if (date == null) return null; return dateFormat.format(date); } 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); } }