public class TimeCategory
extends Object
Apply a number of methods to allow convenient Date/Time manipulation,such as:
use (groovy.time.TimeCategory) {
// application on numbers:
println 1.minute.from.now
println 10.hours.ago
// application on dates
def someDate = new Date()
println someDate - 3.months
}
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static Duration |
getDay(Integer self)Alias for getDays(Integer). |
|
public static Duration |
getDaylightSavingsOffset(Date self)Get the DST offset (if any) for the default locale and the given date. |
|
public static Duration |
getDaylightSavingsOffset(BaseDuration self)Gets the daylight savings offset for the supplied duration interpreted as a date. |
|
public static Duration |
getDays(Integer self)Returns a day-based duration for the supplied number of days. |
|
public static TimeDuration |
getHour(Integer self)Alias for getHours(Integer). |
|
public static TimeDuration |
getHours(Integer self)Returns an hour-based duration for the supplied number of hours. |
|
public static TimeDuration |
getMillisecond(Integer self)Alias for getMilliseconds(Integer). |
|
public static TimeDuration |
getMilliseconds(Integer self)Returns a millisecond-based duration for the supplied number of milliseconds. |
|
public static TimeDuration |
getMinute(Integer self)Alias for getMinutes(Integer). |
|
public static TimeDuration |
getMinutes(Integer self)Returns a minute-based duration for the supplied number of minutes. |
|
public static DatumDependentDuration |
getMonth(Integer self)Alias for getMonths(Integer). |
|
public static DatumDependentDuration |
getMonths(Integer self)Returns a month-based duration for the supplied number of months. |
|
public static Duration |
getRelativeDaylightSavingsOffset(Date self, Date other)Return a Duration representing the DST difference (if any) between two dates. |
|
public static TimeDuration |
getSecond(Integer self)Alias for getSeconds(Integer). |
|
public static TimeDuration |
getSeconds(Integer self)Returns a second-based duration for the supplied number of seconds. |
|
public static TimeZone |
getTimeZone(Date self)Retrieves the default TimeZone for a date by using the default Locale settings. |
|
public static Duration |
getWeek(Integer self)Alias for getWeeks(Integer). |
|
public static Duration |
getWeeks(Integer self)Returns a week-based duration for the supplied number of weeks. |
|
public static DatumDependentDuration |
getYear(Integer self)Alias for getYears(Integer). |
|
public static DatumDependentDuration |
getYears(Integer self)Returns a year-based duration for the supplied number of years. |
|
public static Date |
minus(Date date, BaseDuration duration)Subtracts a duration from a date. |
|
public static TimeDuration |
minus(Date lhs, Date rhs)Subtract one date from the other. |
|
public static Date |
plus(Date date, BaseDuration duration)Adds a duration to a date. |
Alias for getDays(Integer).
self - the number of daysGet the DST offset (if any) for the default locale and the given date.
self - a DateGets the daylight savings offset for the supplied duration interpreted as a date.
self - the duration to inspectReturns a day-based duration for the supplied number of days.
self - the number of daysAlias for getHours(Integer).
self - the number of hoursReturns an hour-based duration for the supplied number of hours.
self - the number of hoursAlias for getMilliseconds(Integer).
self - the number of millisecondsReturns a millisecond-based duration for the supplied number of milliseconds.
self - the number of millisecondsAlias for getMinutes(Integer).
self - the number of minutesReturns a minute-based duration for the supplied number of minutes.
self - the number of minutesAlias for getMonths(Integer).
self - the number of monthsReturns a month-based duration for the supplied number of months.
self - the number of monthsReturn a Duration representing the DST difference (if any) between two dates. i.e. if one date is before the DST changeover, and the other date is after, the resulting duration will represent the DST offset.
self - a Dateother - another DateAlias for getSeconds(Integer).
self - the number of secondsReturns a second-based duration for the supplied number of seconds.
self - the number of seconds Retrieves the default TimeZone for a date by using the default Locale
settings. Recommended that you use TimeZone.getDefault() instead.
self - a DateAlias for getWeeks(Integer).
self - the number of weeksReturns a week-based duration for the supplied number of weeks.
self - the number of weeksAlias for getYears(Integer).
self - the number of yearsReturns a year-based duration for the supplied number of years.
self - the number of yearsSubtracts a duration from a date.
date - the base dateduration - the duration to subtractSubtract one date from the other.
lhs - a Daterhs - another DateAdds a duration to a date.
date - the base dateduration - the duration to add