Here you can find the source of formatDateTime(Date date)
public static String formatDateTime(Date date) throws ParseException
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatDateTime(Date date) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return dateFormat.format(date); }//from ww w. j av a2s. co m public static String format(Date date, String patten) throws ParseException { SimpleDateFormat dateFormat = new SimpleDateFormat(patten); return dateFormat.format(date); } }