Here you can find the source of formatDateTime(Date d)
public static String formatDateTime(Date d)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; public class Main { public static final String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static String formatDateTime(Date d) { return format(d, DATETIME_FORMAT); }/*ww w . j a v a2s . c o m*/ public static String format(Date d, String format) { return format(d, format, Locale.getDefault()); } public static String format(Date d, String format, Locale locale) { if (d == null) return ""; DateFormat df = new SimpleDateFormat(format, locale); return df.format(d); } }