Top Description Constructors Methods
groovy.time

public Class TimeCategory

extends Object
Class Inheritance
Imports
java.util.Calendar, .Date, .TimeZone

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
}
See Also
BaseDuration

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Duration
getDay(final Integer self)

public static Duration

Returns:

the DST offset as a Duration.
getDaylightSavingsOffset
(Date
a Date
self
)

Get the DST offset (if any) for the default locale and the given date.

public static Duration
public static Duration
getDays(final Integer self)

public static TimeDuration
getHour(final Integer self)

public static TimeDuration
getHours(final Integer self)

public static TimeDuration
getMillisecond(final Integer self)

public static TimeDuration
public static TimeDuration
getMinute(final Integer self)

public static TimeDuration
getMinutes(final Integer self)

public static DatumDependentDuration
getMonth(final Integer self)

public static DatumDependentDuration
getMonths(final Integer self)

public static Duration

Returns:

a Duration
getRelativeDaylightSavingsOffset
(Date
a Date
self
,
Date
another Date
other
)

Return a Duration representing the DST difference (if any) between two dates.

public static TimeDuration
getSecond(final Integer self)

public static TimeDuration
getSeconds(final Integer self)

public static TimeZone

Returns:

the TimeZone
getTimeZone
(Date
a Date
self
)

Deprecated
Retrieves the default TimeZone for a date by using the default Locale settings.
public static Duration
getWeek(final Integer self)

public static Duration
getWeeks(final Integer self)

public static DatumDependentDuration
getYear(final Integer self)

public static DatumDependentDuration
getYears(final Integer self)

public static Date
minus(final Date date, final BaseDuration duration)

public static TimeDuration

Returns:

a Duration
minus
(final Date
a Date
lhs
,
final Date
another Date
rhs
)

Subtract one date from the other.

public static Date
plus(final Date date, final BaseDuration duration)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

TimeCategoryback to summary
public TimeCategory()

Method Detail

getDayback to summary
public static Duration getDay(final Integer self)
getDaylightSavingsOffsetback to summary
public static Duration getDaylightSavingsOffset(Date self)

Get the DST offset (if any) for the default locale and the given date.

Parameters
self:Date

a Date

Returns:Duration

the DST offset as a Duration.

getDaylightSavingsOffsetback to summary
public static Duration getDaylightSavingsOffset(BaseDuration self)
getDaysback to summary
public static Duration getDays(final Integer self)
getHourback to summary
public static TimeDuration getHour(final Integer self)
getHoursback to summary
public static TimeDuration getHours(final Integer self)
getMillisecondback to summary
public static TimeDuration getMillisecond(final Integer self)
getMillisecondsback to summary
public static TimeDuration getMilliseconds(final Integer self)
getMinuteback to summary
public static TimeDuration getMinute(final Integer self)
getMinutesback to summary
public static TimeDuration getMinutes(final Integer self)
getMonthback to summary
public static DatumDependentDuration getMonth(final Integer self)
getMonthsback to summary
public static DatumDependentDuration getMonths(final Integer self)
getRelativeDaylightSavingsOffsetback to summary
public static Duration getRelativeDaylightSavingsOffset(Date self, Date other)

Return 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.

Parameters
self:Date

a Date

other:Date

another Date

Returns:Duration

a Duration

getSecondback to summary
public static TimeDuration getSecond(final Integer self)
getSecondsback to summary
public static TimeDuration getSeconds(final Integer self)
getTimeZoneback to summary
public static TimeZone getTimeZone(Date self)

Deprecated

Retrieves the default TimeZone for a date by using the default Locale settings. Recommended that you use TimeZone.getDefault() instead.

Parameters
self:Date

a Date

Returns:TimeZone

the TimeZone

Annotations
@Deprecated
getWeekback to summary
public static Duration getWeek(final Integer self)
getWeeksback to summary
public static Duration getWeeks(final Integer self)
getYearback to summary
public static DatumDependentDuration getYear(final Integer self)
getYearsback to summary
public static DatumDependentDuration getYears(final Integer self)
minusback to summary
public static Date minus(final Date date, final BaseDuration duration)
minusback to summary
public static TimeDuration minus(final Date lhs, final Date rhs)

Subtract one date from the other.

Parameters
lhs:Date

a Date

rhs:Date

another Date

Returns:TimeDuration

a Duration

plusback to summary
public static Date plus(final Date date, final BaseDuration duration)