Here you can find the source of date2String(java.util.Date date, String pattern)
public static String date2String(java.util.Date date, String pattern)
//package com.java2s; import java.text.SimpleDateFormat; public class Main { public static final String PATTERN_STANDARD = "yyyy-MM-dd HH:mm:ss"; public static String date2String(java.util.Date date, String pattern) { if (date == null) { throw new java.lang.IllegalArgumentException("timestamp null illegal"); }// w ww . ja va 2s .c o m if (pattern == null || pattern.equals("")) { pattern = PATTERN_STANDARD; ; } SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(date); } }