Here you can find the source of formatTime(Date date)
public static String formatTime(Date date)
//package com.java2s; //License from project: LGPL import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String formatTime(Date date) { return formatDate(date, "yyyy-MM-dd HH:mm:ss"); }//from w w w .j a va 2s . c o m public static String formatDate(Date date, String format) { if (date == null) { return ""; } SimpleDateFormat simpleDateFORMat = new SimpleDateFormat(format); return simpleDateFORMat.format(date); } public static String formatDate(Date date) { return formatDate(date, "yyyy-MM-dd"); } }