Here you can find the source of getTimeInHHMMSS(Calendar time)
public static String getTimeInHHMMSS(Calendar time)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static String getTimeInHHMMSS(Date time) { Calendar cal = Calendar.getInstance(); cal.setTime(time);/*from ww w. jav a2 s .c o m*/ return getTimeInHHMMSS(cal); } public static String getTimeInHHMMSS(Calendar time) { if (time == null) return "HH:MM"; int h = time.get(Calendar.HOUR_OF_DAY); int m = time.get(Calendar.MINUTE); StringBuilder sb = new StringBuilder(); if (h < 10) sb.append("0"); sb.append(h).append(":"); if (m < 10) sb.append("0"); sb.append(m); // sb.append(":"); // if (s < 10) // sb.append("0"); // sb.append(s); return sb.toString(); } public static String toString(int... results) { StringBuilder sb = new StringBuilder(); sb.append('['); sb.append(' '); for (int i : results) sb.append(i).append(','); sb.setCharAt(sb.length() - 1, ' '); sb.append(']'); return sb.toString(); } }