Here you can find the source of time2String(Date time, DateFormat dateFormat)
public synchronized static String time2String(Date time, 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_TIME_FORMAT = new SimpleDateFormat("HH:mm:ss"); public synchronized static String time2String(Date time, DateFormat dateFormat) { if (time == null) return null; return dateFormat.format(time); }/* www. j a va2s.c o m*/ public static String time2String(Date time, String dateFormat) { if (time == null) return null; return date2String(time, new SimpleDateFormat(dateFormat)); } public static String time2String(Date time) { if (time == null) return null; return date2String(time, DEFAULT_TIME_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); } }