Here you can find the source of getFormatDateTime(Date date, String format)
public static String getFormatDateTime(Date date, String format)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String DEFAULT_FORMAT = "yyyy-MM-dd"; public static String getFormatDateTime(Date date, String format) { SimpleDateFormat sdf;/*from w w w . j a v a 2s .com*/ if (format == null || format.equalsIgnoreCase("")) { sdf = new SimpleDateFormat(DEFAULT_FORMAT); } else { sdf = new SimpleDateFormat(format); } return sdf.format(date); } }