Here you can find the source of toTimeString(Date date)
public static String toTimeString(Date date)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String toTimeString(Date date) { if (date == null) { return null; }//from w ww. j ava 2 s .c o m SimpleDateFormat sdff = new SimpleDateFormat("HH:mm:ss"); String dateStr = sdff.format(getNowDateTime()); return dateStr; } public static Date getNowDateTime() { return Calendar.getInstance().getTime(); } public static String getTime(Date dt, String format) { SimpleDateFormat st = new SimpleDateFormat(format); return st.format(dt); } }