Groovy JDK

java.util
Class Date

Method Summary
String format(String format)
Return a String representing this date in the given format
int getAt(int field)
Support the subscript operator for a Date
String getDateString()
Return a string representation of the 'day' portion of this date according to the locale-specific format used by {@link DateFormat}
String getDateTimeString()
Return a string representation of the date and time time portion of this Date instance, according to the locale-specific format used by {@link DateFormat} preset for the day portion and {@link DateFormat#MEDIUM} for the time portion of the string
String getTimeString()
Return a string representation of the time portion of this date according to the locale-specific format used by {@link DateFormat}
Date minus(int days)
Subtract a number of days from this date and returns the new date
Date next()
Increment a Date by one day
static Date parse(String format, String input)
This convenience method acts as a wrapper for {@link SimpleDateFormat}
Date plus(int days)
Add a number of days to this date and returns the new date
Date previous()
Decrement a Date by one day
 
Method Detail

format

public String format(String format)
Return a String representing this date in the given format.

Parameters:
format - the format pattern to use according to {@link SimpleDateFormat}.
Returns:
a string representation of this date.
See:
SimpleDateFormat.

getAt

public int getAt(int field)
Support the subscript operator for a Date.

Parameters:
field - a Calendar field, e.g. MONTH.
Returns:
the value for the given field, e.g. FEBRUARY
See:
Calendar.

getDateString

public String getDateString()
Return a string representation of the 'day' portion of this date according to the locale-specific format used by {@link DateFormat}

Returns:
a string representation of this date
See:
DateFormat#getDateInstance(int).
DateFormat#SHORT.

getDateTimeString

public String getDateTimeString()
Return a string representation of the date and time time portion of this Date instance, according to the locale-specific format used by {@link DateFormat}. This method uses the {@link DateFormat#SHORT} preset for the day portion and {@link DateFormat#MEDIUM} for the time portion of the string

Returns:
a string representation of this date and time
See:
DateFormat#getDateTimeInstance(int, int).

getTimeString

public String getTimeString()
Return a string representation of the time portion of this date according to the locale-specific format used by {@link DateFormat}

Returns:
a string representing the time portion of this date
See:
DateFormat#getTimeInstance(int).
DateFormat#MEDIUM.

minus

public Date minus(int days)
Subtract a number of days from this date and returns the new date.

Parameters:
days - the number of days to subtract.
Returns:
the new date

next

public Date next()
Increment a Date by one day.

Returns:
the next days date

parse

public static Date parse(String format, String input)
This convenience method acts as a wrapper for {@link SimpleDateFormat}.

Parameters:
format - pattern used to parse the input string..
input - String to be parsed to create the date instance.
Returns:
a new Date instance representing the parsed input string
See:
SimpleDateFormat#parse(String).

plus

public Date plus(int days)
Add a number of days to this date and returns the new date.

Parameters:
days - the number of days to increase.
Returns:
the new date

previous

public Date previous()
Decrement a Date by one day.

Returns:
the previous days date

Groovy JDK