Java Utililty Methods Calendar Format

List of utility methods to do Calendar Format

Description

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

Method

StringcalToString(Calendar cal)
cal To String
DateFormat f = SimpleDateFormat.getDateInstance(DateFormat.SHORT);
return f.format(cal.getTime());
Stringformat(Calendar cal)
Null-safe method to display a Calendar as a formatted String .
return cal == null ? "null" : "<" + df.format(cal.getTime()) + ">";
Stringformat(Calendar cal)
Formats a Calendar value into a ISO8601-compliant date/time string.
SimpleDateFormat format = new SimpleDateFormat(ISO_FORMAT);
TimeZone tz = cal.getTimeZone();
format.setTimeZone(tz);
StringBuffer tzd = new StringBuffer("Z");
int offset = tz.getRawOffset();
if (offset != 0) {
    int hours = Math.abs((offset / (60 * 1000)) / 60);
    int minutes = Math.abs((offset / (60 * 1000)) % 60);
...
Stringformat(Calendar cal, String format)
format
if (cal == null)
    return "";
SimpleDateFormat myFormatter = new SimpleDateFormat(format);
return myFormatter.format(cal.getTime());
Stringformat(Calendar cal, String pattern)
format
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
return formatter.format(calendarToDate(cal));
Stringformat(Calendar calendar)
format
return new SimpleDateFormat("dd-MM-yyyy").format(calendar.getTime());
Stringformat(Calendar calendar)
format
if (calendar == null) {
    return null;
return dateFormat.format(calendar.getTime());
Stringformat(Calendar calendar)
format a calendar using SimpleDateFormat , with default pattern.
String formatted = "";
if (calendar != null) {
    formatted = new SimpleDateFormat().format(calendar.getTime());
return formatted;
Stringformat(Calendar calendar)
format
if (calendar == null) {
    return null;
return DATE_FORMAT.format(calendar.getTime());
Stringformat(Calendar calendar)
format
return getDateFormat(a).format(calendar.getTime());