Groovy JDK

java.util
Class Calendar

Method Summary
void clearTime()
Clears the time portion of this Calendar instance; Util where it makes sense to compare month/day/year only portions of a Calendar
String format(String pattern)

Shortcut for 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

clearTime

public void clearTime()
 
Clears the time portion of this Calendar instance; Util where it makes sense to compare month/day/year only portions of a Calendar
Since:
1.6.7

format

public String format(String pattern)
 

Shortcut for SimpleDateFormat to output a String representation of this calendar instance. This method respects the Calendar's assigned 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 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 DateFormat#getDateInstance 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.
SimpleDateFormat#format.
Date#format.

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

Groovy JDK