Here you can find the source of date2Str(Date date, String dateFormat)
public static String date2Str(Date date, String dateFormat)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String YYYYMMDDHHMMSS = "yyyy-MM-dd HH:mm:ss"; public static String date2Str(Date date) { return date2Str(date, YYYYMMDDHHMMSS); }//from ww w . j a va 2 s . c om public static String date2Str(Date date, String dateFormat) { if (date == null) { return null; } SimpleDateFormat df = new SimpleDateFormat(dateFormat); return df.format(date); } }