Here you can find the source of dateToString(Date date, String dateFormat)
public static String dateToString(Date date, String dateFormat)
//package com.java2s; //License from project: LGPL import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String dateToString(Date date, String dateFormat) { if (date == null) return ""; try {/*ww w . j a v a 2 s . c om*/ return new SimpleDateFormat(dateFormat).format(date); } catch (Exception e) { e.printStackTrace(); return ""; } } }