Here you can find the source of format(Date date, String dateFormat)
public static String format(Date date, String dateFormat)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { /**/*from www . j a v a2 s. c om*/ * yyyy-MM-dd HH:mm:ss */ public static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static String format(Date date) { return format(date, DATETIME_FORMAT); } public static String format(Date date, String dateFormat) { if (date != null) { SimpleDateFormat format = new SimpleDateFormat(dateFormat); String dateString = format.format(date); return dateString; } return null; } }