Here you can find the source of getTime(Date date)
public static String getTime(Date date)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getTime(Date date) { return format(date, "HH:mm:ss"); }//from w w w . j a va2s.c o m public static String format(Date date, String format) { String result = ""; try { if (date != null) { DateFormat dateFormat = new SimpleDateFormat(format); result = dateFormat.format(date); } } catch (Exception localException) { } return result; } public static String format(Date date) { return format(date, "yyyy-MM-dd"); } }