Here you can find the source of dateToString(Date d)
public static String dateToString(Date d)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static final String DATE_FORMAT = "yyyy/MM/dd"; public static String dateToString(Date d) { SimpleDateFormat sd = new SimpleDateFormat(DATE_FORMAT); String date = sd.format(d); return date; }//from w ww.j a v a 2s.c o m public static String format(Date d, String format) { return format(d, format, Locale.getDefault()); } public static String format(Date d, String format, Locale locale) { if (d == null) return ""; DateFormat df = new SimpleDateFormat(format, locale); return df.format(d); } }