Here you can find the source of date2string(Date date)
public static String date2string(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String date2string(Date date) { return date2string(date, "yyyy-MM-dd HH:mm:ss"); }/* w w w . j a v a 2 s . c o m*/ public static String date2string(long date) { Date theTime = new Date(date); return date2string(theTime); } public static String date2string(Date date, String format) { if (date == null) { date = new Date(); } if (format == null) { format = "yyyy-MM-dd HH:mm:ss"; } SimpleDateFormat sf = new SimpleDateFormat(format); return sf.format(date); } }