Here you can find the source of toString(Date time)
public static String toString(Date time)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String toString(Date time) { return getDateString(time, "yyyy-MM-dd HH:mm:ss"); }//from w ww . j av a 2 s. c o m public static String getDateString(Date date, String dateFormat) { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); return sdf.format(date); } }