Here you can find the source of dateToStr(Date date)
public static String dateToStr(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final String NORMAL_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static String dateToStr(Date date) { if (date == null) { return ""; }//from ww w . java 2 s . c o m return dateToString(date, NORMAL_PATTERN); } public static String dateToStr() { return dateToStr(new Date()); } public static String dateToString(Date date, String pattern) { if (date == null) { date = new Date(); } SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(date); } @Deprecated public static String dateToString(Date date) { return dateToStr(date); } }