Here you can find the source of formatDate(Date date, String format, Locale locale)
public static String formatDate(Date date, String format, Locale locale)
//package com.java2s; /*//from w w w . ja v a 2 s .c o m * Distributable under LGPL v3 license. * See terms of license at https://github.com/Yunfeng/schotel/blob/master/LICENSE */ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static String formatDate(Date date, String format, Locale locale) { SimpleDateFormat sdf = new SimpleDateFormat(format, locale); return sdf.format(date); } public static String formatDate(Date date, String format) { if (format == null) format = "yyyy-MM-dd HH:mm:ss"; SimpleDateFormat sdf = new SimpleDateFormat(format); return sdf.format(date); } }