|
Groovy JDK |
Method Summary | |
---|---|
String
|
format(String format)
Create a String representation of this date according to the given format pattern. |
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 {@link DateFormat#SHORT} default format. |
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}. |
String
|
getTimeString()
Return a string representation of the time portion of this date according to the locale-specific {@link DateFormat#MEDIUM} default format. |
Date
|
minus(int days)
Subtract a number of days from this date and returns the new date. |
int
|
minus(Date then)
Subtract another Date from this one and return the number of days of the difference. |
Date
|
next()
Increment a Date by one day. |
static Date
|
parse(String format, String input)
Parse a String into a Date instance using the given pattern. |
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 |
---|
public String format(String format)
Create a String representation of this date according to the given format pattern.
For example, if the system timezone is GMT,
new Date(0).format('MM/dd/yy')
would return the string
"01/01/70"
. See documentation for {@link SimpleDateFormat}
for format pattern use.
Note that a new DateFormat instance is created for every invocation of this method (for thread safety).
format
- the format pattern to use according to {@link SimpleDateFormat}.public int getAt(int field)
field
- a Calendar field, e.g. MONTH.public String getDateString()
Return a string representation of the 'day' portion of this date
according to the locale-specific {@link DateFormat#SHORT} default format.
For an "en_UK" system locale, this would be dd/MM/yy
.
Note that a new DateFormat instance is created for every invocation of this method (for thread safety).
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 output string.
Note that a new DateFormat instance is created for every invocation of this method (for thread safety).
public String getTimeString()
Return a string representation of the time portion of this date
according to the locale-specific {@link DateFormat#MEDIUM} default format.
For an "en_UK" system locale, this would be HH:MM:ss
.
Note that a new DateFormat instance is created for every invocation of this method (for thread safety).
public Date minus(int days)
days
- the number of days to subtract.public int minus(Date then)
then
- another Date.public Date next()
public static Date parse(String format, String input)
Note that a new SimpleDateFormat instance is created for every invocation of this method (for thread safety).
format
- pattern used to parse the input string..input
- String to be parsed to create the date instance.public Date plus(int days)
days
- the number of days to increase.public Date previous()
|
Groovy JDK |