Overview | Package | Class | Tree | Deprecated | Index | Help
| Groovy JDK

## java.util
Class Calendar

Method Summary
`String` | `format(String pattern)` Shortcut for {@link SimpleDateFormat} to output a String representation of this calendar instance.
`int` | `minus(Calendar then)` Subtract another date from this one and return the number of days of the difference.

Method Detail

### format

    public String format(String pattern)

  Shortcut for {@link SimpleDateFormat} to output a String representation of this calendar instance. This method respects the Calendar's assigned {@link TimeZone}, whereas calling `cal.time.format('HH:mm:ss')` would use the system timezone.

  Note that Calendar equivalents of `date.getDateString()` and variants do not exist because those methods are Locale-dependent. Although a Calendar may be assigned a {@link Locale}, that information is lost and therefore cannot be used to control the default date/time formats provided by these methods. Instead, the system Locale would always be used. The alternative is to simply call {@link DateFormat#getDateInstance(int, Locale)} and pass the same Locale that was used for the Calendar.

Parameters:
  `pattern` - format pattern.

Returns:
  String representation of this calendar with the given format.

Since:
  1.6.0

See:
  DateFormat#setTimeZone(TimeZone).
  SimpleDateFormat#format(Date).
  #format(Date, String).

### minus

    public int minus(Calendar then)

  Subtract another date from this one and return the number of days of the difference. Date self = Date then + (Date self - Date then) IOW, if self is before then the result is a negative value.

Parameters:
  `then` - another Calendar.

Returns:
  number of days

Since:
  1.6.0

Overview | Package | Class | Tree | Deprecated | Index | Help
| Groovy JDK