Here you can find the source of format(Date date, String pattern)
public static String format(Date date, String pattern)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"; public static final String DATE_PATTERN_SS = "yyyyMMddHHmmssSS"; public static String format(Date date) { SimpleDateFormat sdf = new SimpleDateFormat(YYYY_MM_DD_HH_MM_SS); return sdf.format(date); }/*from www .j a v a2s . c o m*/ public static String format(Date date, String pattern) { return date == null ? " " : new SimpleDateFormat(pattern).format(date); } public static String format() { SimpleDateFormat sdf = new SimpleDateFormat(DATE_PATTERN_SS); return sdf.format(new Date()); } }