Here you can find the source of formatTime(final Calendar cal)
public static String formatTime(final Calendar cal)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String formatTime(final Calendar cal) { if (cal == null) { throw new NullPointerException("cal"); }//from w w w . j av a 2 s . c om return formatTime(cal.getTime()); } public static String formatTime(final Date date) { if (date == null) { throw new NullPointerException("date"); } DateFormat formatter = new SimpleDateFormat("HH:mm:ss"); return formatter.format(date); } }