Here you can find the source of dateToString(Date date)
public static String dateToString(Date date)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static final String DEFAULT_DATE_FORMATE = "yyyy-MM-dd HH:mm:ss"; public static String dateToString(Date date) { if (date == null) return ""; else {/*from w w w. j a v a 2 s . c o m*/ SimpleDateFormat sdFormat = new SimpleDateFormat(DEFAULT_DATE_FORMATE, Locale.getDefault()); String str_Date = sdFormat.format(date); return str_Date; } } }