Package groovy.time
Class TimeCategory
java.lang.Object
groovy.time.TimeCategory
public class TimeCategory
extends java.lang.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
-
Constructor Summary
Constructors Constructor Description TimeCategory() -
Method Summary
Modifier and Type Method Description static DurationgetDay(java.lang.Integer self)static DurationgetDaylightSavingsOffset(BaseDuration self)static DurationgetDaylightSavingsOffset(java.util.Date self)Get the DST offset (if any) for the default locale and the given date.static DurationgetDays(java.lang.Integer self)static TimeDurationgetHour(java.lang.Integer self)static TimeDurationgetHours(java.lang.Integer self)static TimeDurationgetMillisecond(java.lang.Integer self)static TimeDurationgetMilliseconds(java.lang.Integer self)static TimeDurationgetMinute(java.lang.Integer self)static TimeDurationgetMinutes(java.lang.Integer self)static DatumDependentDurationgetMonth(java.lang.Integer self)static DatumDependentDurationgetMonths(java.lang.Integer self)static DurationgetRelativeDaylightSavingsOffset(java.util.Date self, java.util.Date other)Return a Duration representing the DST difference (if any) between two dates.static TimeDurationgetSecond(java.lang.Integer self)static TimeDurationgetSeconds(java.lang.Integer self)static java.util.TimeZonegetTimeZone(java.util.Date self)Deprecated.static DurationgetWeek(java.lang.Integer self)static DurationgetWeeks(java.lang.Integer self)static DatumDependentDurationgetYear(java.lang.Integer self)static DatumDependentDurationgetYears(java.lang.Integer self)static java.util.Dateminus(java.util.Date date, BaseDuration duration)static TimeDurationminus(java.util.Date lhs, java.util.Date rhs)Subtract one date from the other.static java.util.Dateplus(java.util.Date date, BaseDuration duration)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
TimeCategory
public TimeCategory()
-
-
Method Details
-
plus
-
minus
-
getTimeZone
@Deprecated public static java.util.TimeZone getTimeZone(java.util.Date self)Deprecated.Retrieves the default TimeZone for a date by using the default Locale settings. Recommended that you useTimeZone.getDefault()instead.- Parameters:
self- a Date- Returns:
- the TimeZone
-
getDaylightSavingsOffset
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.
-
getDaylightSavingsOffset
-
getRelativeDaylightSavingsOffset
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 Dateother- another Date- Returns:
- a Duration
-
minus
Subtract one date from the other.- Parameters:
lhs- a Daterhs- another Date- Returns:
- a Duration
-
getMonths
-
getMonth
-
getYears
-
getYear
-
getWeeks
-
getWeek
-
getDays
-
getDay
-
getHours
-
getHour
-
getMinutes
-
getMinute
-
getSeconds
-
getSecond
-
getMilliseconds
-
getMillisecond
-