Here you can find the source of format(Date date)
public static String format(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 format(Date date) throws ParseException { if (date == null) { return null; }/*from w w w .j a v a 2s .c o m*/ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); return sdf.format(date); } }