Java tutorial
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String date2string(Date date, String format) { if (date == null) { return ""; } SimpleDateFormat sdf = new SimpleDateFormat(format); String result = sdf.format(date); sdf = null; return result; } public static String date2string(Date date) { return date2string(date, "yyyy-MM-dd"); } }