Here you can find the source of dateFormat(Date date)
public static String dateFormat(Date date)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String dateFormat(Date date) { if (date != null) { DateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); return sf.format(date); } else {//from w w w . j av a2 s. c om return ""; } } public static String dateFormat(Date date, String style) { if (date != null) { DateFormat sf = new SimpleDateFormat(style); return sf.format(date); } else { return ""; } } }