Java Utililty Methods Calendar to Time

List of utility methods to do Calendar to Time

Description

The list of methods to do Calendar to Time are organized into topic(s).

Method

StringcalendarToTimeString(Calendar calendar)
calendar To Time String
String time = Integer.toString(calendar.get(Calendar.HOUR_OF_DAY));
time += ":";
if (calendar.get(Calendar.MINUTE) < 10) {
    time += "0";
time += Integer.toString(calendar.get(Calendar.MINUTE));
return time;
StringgetCalendarStringTime(Calendar c)
Get time from a Calendar
DateFormat dfm = new SimpleDateFormat("HH:mm:ss");
return dfm.format(c.getTime());
StringgetTime(Calendar c)
get Time
return getDate(c.getTime(), "HH:mm:ss");
StringgetTime(Calendar calendar)
get Time
return getTime(calendar.getTime());
StringgetTime(Calendar calendar)
get Time
return getTime(calendar.getTime());
StringgetTime(Calendar pCalendar_)
get Time
SimpleDateFormat pSimpleDateFormat = new SimpleDateFormat("HH:mm:ss");
pSimpleDateFormat.setCalendar(pCalendar_);
String sRetVal = pSimpleDateFormat.format(pCalendar_.getTime());
return sRetVal;
StringgetTimeString(Calendar cal)
Returns the time given by cal as a String formatted as needed.
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
return sdf.format(cal.getTime()).replace("+0000", "Z");
StringgetTimeString(Calendar calendar)
get Time String
StringBuffer sb = new StringBuffer();
sb.append(String.valueOf(calendar.get(Calendar.YEAR)))
        .append(valueOfString(String.valueOf(calendar.get(Calendar.MONTH) + 1), 2))
        .append(valueOfString(String.valueOf(calendar.get(Calendar.DAY_OF_MONTH)), 2))
        .append(valueOfString(String.valueOf(calendar.get(Calendar.HOUR_OF_DAY)), 2))
        .append(valueOfString(String.valueOf(calendar.get(Calendar.MINUTE)), 2))
        .append(valueOfString(String.valueOf(calendar.get(Calendar.SECOND)), 2))
        .append(valueOfString(String.valueOf(calendar.get(Calendar.MILLISECOND)), 3));
...
StringprintTime(Calendar value)
print Time
if (value == null)
    throw new IllegalArgumentException("Can't print time value!");
else
    return getTimeFormat().format(value.getTime());