Here you can find the source of formatTime(Date time)
public static String formatTime(Date time) throws Exception
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public static String formatTime(long time) throws Exception { return DATE_FORMAT.format(new Date(time)); }//ww w .ja v a 2 s . c o m public static String formatTime(Date time) throws Exception { return DATE_FORMAT.format(time); } }