Here you can find the source of DateToString(Date date, String pattern)
public static String DateToString(Date date, String pattern)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String DateToString(Date date, String pattern) { String strDateTime = null; SimpleDateFormat formater = new SimpleDateFormat(pattern); strDateTime = date == null ? null : formater.format(date); return strDateTime; }//from w w w.j a va 2s .c om public static String DateToString(Date date) { String _pattern = "yyyy-MM-dd"; return date == null ? null : DateToString(date, _pattern); } }