Here you can find the source of formatDateTime(Date d)
public static String formatDateTime(Date d)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static final String DATETIME_PATTERN = "yyyy-MM-dd HH:mm:ss"; public static String formatDateTime(Date d) { return formatDateTime(d, DATETIME_PATTERN); }/*www .j a va 2 s . c om*/ public static String formatDateTime(Date d, String pattern) { SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(d); } }