Here you can find the source of formatTime(java.util.Date date)
public static String formatTime(java.util.Date date)
//package com.java2s; public class Main { public static String formatTime(java.util.Date date) { if (date == null) { return ""; }//from w w w . ja va2 s .c o m return format(date, "yyyy/MM/dd HH:mm:ss"); } public static String format(java.util.Date date, String format) { String result = ""; try { if (date != null) { java.text.DateFormat df = new java.text.SimpleDateFormat(format); result = df.format(date); } } catch (Exception e) { } return result; } public static String format(java.util.Date date) { if (date == null) { return ""; } return format(date, "yyyy/MM/dd"); } }