Here you can find the source of convertTimeToString(Calendar time)
Parameter | Description |
---|---|
time | Calendar of the time to convert |
public static String convertTimeToString(Calendar time)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { /**//from w w w. ja v a 2 s . c o m * Converts time as Calendar in the string format 'hh:mm:ss'. * * @param time * Calendar of the time to convert * @return Date object of the given time */ public static String convertTimeToString(Calendar time) { String timeText = ""; int hour = time.get(Calendar.HOUR_OF_DAY); if (hour < 10) { timeText += "0"; } timeText += hour + ":"; int minute = time.get(Calendar.MINUTE); if (minute < 10) { timeText += "0"; } timeText += minute + ":"; int second = time.get(Calendar.SECOND); if (second < 10) { timeText += "0"; } timeText += second; return timeText; } }