Here you can find the source of dateFormat(Date date, String pattern)
public static String dateFormat(Date date, String pattern)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String dateFormat(Date date, String pattern) { if (date == null || isNullString(pattern)) { return ""; }//w w w .jav a 2 s. co m SimpleDateFormat format = new SimpleDateFormat(pattern); return format.format(date); } public static boolean isNullString(String target) { if (target == null || "".equals(target.trim())) { return true; } return false; } }