Package com.isomorphic.util.date

# Class RelativeDate

java.lang.Object
com.isomorphic.util.date.RelativeDate

All Implemented Interfaces:
  `Comparable<RelativeDate>`

public class RelativeDate extends Object implements 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 Type
  Method
  Description
  `GregorianCalendar`
  `getAbsoluteDate(boolean isLogicalDate)`
  Gets the absolute date for this relative date with the current date and time as the relevance point.
  `GregorianCalendar`
  `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 timezone
  `GregorianCalendar`
  `getAbsoluteDate(Date baseDate, boolean isLogicalDate, TimeZone tz)`
  Gets the absolute date for this relative date with a base date and time as the relevance point.
  `String`
  `getDirection()`
  Returns the direction sign for this relative date.
  `String`
  `getPeriod()`
  Returns the period for this relative date.
  `RelativeDate`
  `getQualifier()`
  Returns the qualifier for this relative date, the qualifier is another relative date.
  `RelativeDateRangePosition`
  `getRangePosition()`
  Returns the `RelativeDateRangePosition` 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 the `RelativeDateRangePosition` for this relative date.

- ## Method Details

  - ### getAbsoluteDate

    public GregorianCalendar getAbsoluteDate(boolean isLogicalDate)
    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

    public GregorianCalendar 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 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

    public GregorianCalendar getAbsoluteDate(Date baseDate, boolean isLogicalDate, TimeZone tz)
    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

    public RelativeDateRangePosition getRangePosition()
    Returns the `RelativeDateRangePosition` for this relative date.
    Returns:
      the range position.

  - ### setRangePosition

    public void setRangePosition(RelativeDateRangePosition rangePosition)
    Sets the `RelativeDateRangePosition` for this relative date.
    Parameters:
      `rangePosition` -

  - ### getDirection

    public String getDirection()
    Returns the direction sign for this relative date.
    Returns:
      either '+' or '-'.

  - ### getQualifier

    public RelativeDate 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

    public String getPeriod()
    Returns the period for this relative date. This will usually be on of the values in `Period`.
    Returns:
      the period.