Package com.isomorphic.util.date
Class RelativeDate
java.lang.Object
com.isomorphic.util.date.RelativeDate
- All Implemented Interfaces:
Comparable<RelativeDate>
Representation of a relative date. Given a string or
RelativeDateShortcut
an absolute date can be retrieved based on a fixed point in time as the point of relevance. A relative date can also contain a RelativeDateRangePosition
which is only used if the relative date string is a RelativeDateShortcut
. For instance, if RelativeDateShortcut.TODAY
is used we don't know if that means the start or the end of today, use the range position to specify which is true.
-
Method Summary
Modifier and TypeMethodDescriptiongetAbsoluteDate
(boolean isLogicalDate) Gets the absolute date for this relative date with the current date and time as the relevance point.getAbsoluteDate
(Date baseDate, boolean isLogicalDate) Gets the absolute date for this relative date with a base date and time as the relevance point, based on the server timezonegetAbsoluteDate
(Date baseDate, boolean isLogicalDate, TimeZone tz) Gets the absolute date for this relative date with a base date and time as the relevance point.Returns the direction sign for this relative date.Returns the period for this relative date.Returns the qualifier for this relative date, the qualifier is another relative date.Returns theRelativeDateRangePosition
for this relative date.int
getValue()
Returns the value of this relative date, the value is the number of units.void
setRangePosition
(RelativeDateRangePosition rangePosition) Sets theRelativeDateRangePosition
for this relative date.
-
Method Details
-
getAbsoluteDate
Gets the absolute date for this relative date with the current date and time as the relevance point.- Parameters:
isLogicalDate
- false if this date should include the time.- Returns:
- a gregorian calendar.
-
getAbsoluteDate
Gets the absolute date for this relative date with a base date and time as the relevance point, based on the server timezone- Parameters:
baseDate
- the relevance point to get the absolute date for.isLogicalDate
- false if this date should include the time.- Returns:
- a gregorian calendar.
-
getAbsoluteDate
Gets the absolute date for this relative date with a base date and time as the relevance point.- Parameters:
baseDate
- the relevance point to get the absolute date for.isLogicalDate
- false if this date should include the time.tz
- the base TimeZone of the returned GregorianCalendar. If null, uses server timezone- Returns:
- a gregorian calendar.
-
getRangePosition
Returns theRelativeDateRangePosition
for this relative date.- Returns:
- the range position.
-
setRangePosition
Sets theRelativeDateRangePosition
for this relative date.- Parameters:
rangePosition
-
-
getDirection
Returns the direction sign for this relative date.- Returns:
- either '+' or '-'.
-
getQualifier
Returns the qualifier for this relative date, the qualifier is another relative date.- Returns:
- the qualifier.
-
getValue
public int getValue()Returns the value of this relative date, the value is the number of units.- Returns:
- the value.
-
getPeriod
Returns the period for this relative date. This will usually be on of the values inPeriod
.- Returns:
- the period.
-