Here you can find the source of format(Date date, String format)
public static String format(Date date, String format)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String DATE_FORMAT = "yyyy-MM-dd"; /**//w w w .j a v a 2 s. c o m * @throws CloudException * * @Title: format * @param: date * @param: format * @return: Date * @throws */ public static Date format(String date, String format) { try { return new SimpleDateFormat(format).parse(date); } catch (Exception e) { e.printStackTrace(); } return null; } /** * @throws CloudException * @Title: format * @param: date * @return: Date * @throws */ public static Date format(String date) { return format(date, DATE_FORMAT); } /** * * @Title: format * @param: date * @param: format * @return: String * @throws */ public static String format(Date date, String format) { return new SimpleDateFormat(format).format(date); } /** * * @Title: format * @param: date * @return: String * @throws */ public static String format(Date date) { return format(date, DATE_FORMAT); } }