[Java] Class TimeCategory

  • groovy.time.TimeCategory
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
 }
 
See Also:
BaseDuration

Methods Summary

Methods
Type Params Return Type Name and description
public static Duration getDay(Integer self)
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)
public static Duration getDays(Integer self)
public static TimeDuration getHour(Integer self)
public static TimeDuration getHours(Integer self)
public static TimeDuration getMillisecond(Integer self)
public static TimeDuration getMilliseconds(Integer self)
public static TimeDuration getMinute(Integer self)
public static TimeDuration getMinutes(Integer self)
public static DatumDependentDuration getMonth(Integer self)
public static DatumDependentDuration getMonths(Integer self)
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)
public static TimeDuration getSeconds(Integer self)
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)
public static Duration getWeeks(Integer self)
public static DatumDependentDuration getYear(Integer self)
public static DatumDependentDuration getYears(Integer self)
public static Date minus(Date date, BaseDuration duration)
public static TimeDuration minus(Date lhs, Date rhs)
Subtract one date from the other.
public static Date plus(Date date, BaseDuration duration)

Inherited Methods Summary

Inherited Methods
Methods inherited from class Name
class Object wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Method Detail

public static Duration getDay(Integer self)

public static Duration getDaylightSavingsOffset(Date self)

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

Parameters:
self - a Date
Returns:
the DST offset as a Duration.

public static Duration getDaylightSavingsOffset(BaseDuration self)

public static Duration getDays(Integer self)

public static TimeDuration getHour(Integer self)

public static TimeDuration getHours(Integer self)

public static TimeDuration getMillisecond(Integer self)

public static TimeDuration getMilliseconds(Integer self)

public static TimeDuration getMinute(Integer self)

public static TimeDuration getMinutes(Integer self)

public static DatumDependentDuration getMonth(Integer self)

public static DatumDependentDuration getMonths(Integer self)

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 - a Date
other - another Date
Returns:
a Duration

public static TimeDuration getSecond(Integer self)

public static TimeDuration getSeconds(Integer self)

@Deprecated public static TimeZone getTimeZone(Date self)

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

Parameters:
self - a Date
Returns:
the TimeZone

public static Duration getWeek(Integer self)

public static Duration getWeeks(Integer self)

public static DatumDependentDuration getYear(Integer self)

public static DatumDependentDuration getYears(Integer self)

public static Date minus(Date date, BaseDuration duration)

public static TimeDuration minus(Date lhs, Date rhs)

Subtract one date from the other.

Parameters:
lhs - a Date
rhs - another Date
Returns:
a Duration

public static Date plus(Date date, BaseDuration duration)

© 2003-2020 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/3.0.7/html/gapi/groovy/time/TimeCategory.html