Package groovy.time
Class BaseDuration
java.lang.Object
groovy.time.BaseDuration
- All Implemented Interfaces:
Comparable<BaseDuration>
- Direct Known Subclasses:
DatumDependentDuration,Duration
Deprecated.
Base class for date and time durations.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated.Helper for computing dates relative to the current time. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final intDeprecated.Day component.protected final intDeprecated.Hour component.protected final intDeprecated.Millisecond component.protected final intDeprecated.Minute component.protected final intDeprecated.Month component.protected final intDeprecated.Second component.protected final intDeprecated.Year component. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseDuration(int days, int hours, int minutes, int seconds, int millis) Deprecated.Creates a duration without year or month components.protectedBaseDuration(int years, int months, int days, int hours, int minutes, int seconds, int millis) Deprecated.Creates a duration with date and time components. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(BaseDuration otherDuration) Deprecated.Compares this duration with another by their millisecond values.abstract DategetAgo()Deprecated.Returns the date represented by this duration ago.intgetDays()Deprecated.Returns the day component.abstract BaseDuration.FromgetFrom()Deprecated.Returns a helper for computing dates relative to now.intgetHours()Deprecated.Returns the hour component.intDeprecated.Returns the millisecond component.intDeprecated.Returns the minute component.intDeprecated.Returns the month component.intDeprecated.Returns the second component.intgetYears()Deprecated.Returns the year component.Deprecated.Adds this duration to the supplied date.abstract longDeprecated.Converts this duration to milliseconds.toString()Deprecated.Returns a human-readable representation of this duration.
-
Field Details
-
years
protected final int yearsDeprecated.Year component. -
months
protected final int monthsDeprecated.Month component. -
days
protected final int daysDeprecated.Day component. -
hours
protected final int hoursDeprecated.Hour component. -
minutes
protected final int minutesDeprecated.Minute component. -
seconds
protected final int secondsDeprecated.Second component. -
millis
protected final int millisDeprecated.Millisecond component.
-
-
Constructor Details
-
BaseDuration
protected BaseDuration(int years, int months, int days, int hours, int minutes, int seconds, int millis) Deprecated.Creates a duration with date and time components.- Parameters:
years- the year componentmonths- the month componentdays- the day componenthours- the hour componentminutes- the minute componentseconds- the second componentmillis- the millisecond component
-
BaseDuration
protected BaseDuration(int days, int hours, int minutes, int seconds, int millis) Deprecated.Creates a duration without year or month components.- Parameters:
days- the day componenthours- the hour componentminutes- the minute componentseconds- the second componentmillis- the millisecond component
-
-
Method Details
-
getYears
public int getYears()Deprecated.Returns the year component.- Returns:
- the year component
-
getMonths
public int getMonths()Deprecated.Returns the month component.- Returns:
- the month component
-
getDays
public int getDays()Deprecated.Returns the day component.- Returns:
- the day component
-
getHours
public int getHours()Deprecated.Returns the hour component.- Returns:
- the hour component
-
getMinutes
public int getMinutes()Deprecated.Returns the minute component.- Returns:
- the minute component
-
getSeconds
public int getSeconds()Deprecated.Returns the second component.- Returns:
- the second component
-
getMillis
public int getMillis()Deprecated.Returns the millisecond component.- Returns:
- the millisecond component
-
plus
Deprecated.Adds this duration to the supplied date.- Parameters:
date- the date to adjust- Returns:
- the adjusted date
-
toString
Deprecated.Returns a human-readable representation of this duration. -
toMilliseconds
public abstract long toMilliseconds()Deprecated.Converts this duration to milliseconds.- Returns:
- the duration in milliseconds
-
getAgo
Deprecated.Returns the date represented by this duration ago.- Returns:
- the computed date
-
getFrom
Deprecated.Returns a helper for computing dates relative to now.- Returns:
- the relative-date helper
-
compareTo
Deprecated.Compares this duration with another by their millisecond values.- Specified by:
compareToin interfaceComparable<BaseDuration>- Parameters:
otherDuration- the duration to compare against- Returns:
- a negative, zero, or positive value as this duration is less than, equal to, or greater than the other
-
org.apache.groovy.dateutil.TimeCategory(and itsjava.util.Date-based duration classes) ororg.apache.groovy.datetime.TimeCategory(producingjava.timetypes). This legacy class is retained, unchanged, for backward compatibility.