Here you can find the source of formatDate(Date date)
public static String formatDate(Date date)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static String formatDate(Date date, String pattern) { DateFormat format = new SimpleDateFormat(pattern); String dateStr = format.format(date); return dateStr; }/*from ww w .j av a 2s. c o m*/ public static String formatDate(Date date) { return formatDate(date, DEFAULT_DATE_PATTERN); } }