Here you can find the source of formatDate(Date date, String format)
public static String formatDate(Date date, String format)
//package com.java2s; /**/*from w w w .java 2 s. c om*/ * Converts a line of text into an array of lower case words using a * BreakIterator.wordInstance(). * <p> * * This method is under the Jive Open Source Software License and was * written by Mark Imbriaco. * * @param text * a String of text to convert into an array of words * @return text broken up into an array of words. */ import java.text.*; import java.util.*; public class Main { public static String formatDate(Date date, String format) { SimpleDateFormat outFormat = new SimpleDateFormat(format); return outFormat.format(date); } /** * Formats a Date object to return a date using the global locale. */ public static String formatDate(Date date) { SimpleDateFormat outFormat = new SimpleDateFormat("yyyy-MM-dd"); return outFormat.format(date); } }