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