com.smartgwt.client.data

## Class RelativeDate

- java.lang.Object
- - com.smartgwt.client.core.JsObject
  - - com.smartgwt.client.core.DataClass
    - - com.smartgwt.client.data.RelativeDate

- All Implemented Interfaces:
    com.google.gwt.event.shared.HasHandlers

      public class RelativeDate
      extends DataClass

  This class is used used to specify a datetime offset within SmartGWT, for example for use in the `RelativeDateItem` class.

  The value attribute is set to a string which specifies the offset from some base date (typically the current date as returned from a call to `new Date();`). See `RelativeDate(String)` for details on the expected format of the string passed in.

  See Also:
    `DateRange.setRelativeStartDate(RelativeDate)`, `DateRange.setRelativeEndDate(RelativeDate)`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static RelativeDate` | `END_OF_MONTH` Builtin option for the end of the current month
    `static RelativeDate` | `END_OF_TODAY` Builtin option for the end of today (one millisecond before the `START_OF_TODAY`
    `static RelativeDate` | `END_OF_TOMORROW` Builtin option for the end of tomorrow (one millisecond before the `START_OF_TOMORROW`)
    `static RelativeDate` | `END_OF_WEEK` Builtin option for the end of the current week
    `static RelativeDate` | `END_OF_YEAR` Builtin option for the end of the current year
    `static RelativeDate` | `END_OF_YESTERDAY` Builtin option for the end of yesterday (one millisecond before the `START_OF_YESTERDAY`)
    `static RelativeDate` | `MONTH_AGO` Builtin option for the current day of the previous month
    `static RelativeDate` | `MONTH_FROM_NOW` Builtin option for the current day of the following month
    `static RelativeDate` | `NOW` Builtin option for this moment - equivalent to calling `new RelativeDate(RelativeDateShortcut.NOW);`
    `static RelativeDate` | `START_OF_MONTH` Builtin option for this moment
    `static RelativeDate` | `START_OF_TODAY` Builtin option for the start of today (same as `TODAY`)
    `static RelativeDate` | `START_OF_TOMORROW` Builtin option for the start of tomorrow (same as `TOMORROW`)
    `static RelativeDate` | `START_OF_WEEK` Builtin option for the start of the current week
    `static RelativeDate` | `START_OF_YEAR` Builtin option for the start of the current year
    `static RelativeDate` | `START_OF_YESTERDAY` Builtin option for the start of yesterday (same as `YESTERDAY`)
    `static RelativeDate` | `TODAY` Builtin option for the start of today
    `static RelativeDate` | `TOMORROW` Builtin option for the start of tomorrow
    `static RelativeDate` | `WEEK_AGO` Builtin option for the current day of the previous week
    `static RelativeDate` | `WEEK_FROM_NOW` Builtin option for the current day of the following week
    `static RelativeDate` | `YESTERDAY` Builtin option for the start of yesterday

    - ### Fields inherited from class com.smartgwt.client.core.DataClass

      `factoryCreated, factoryProperties, readOnly`

    - ### Fields inherited from class com.smartgwt.client.core.JsObject

      `jsObj`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RelativeDate(com.google.gwt.core.client.JavaScriptObject jsObj)`
    `RelativeDate(RelativeDateRangePosition rangePosition, java.lang.String value)`
    `RelativeDate(java.lang.String value)` The value attribute of a RelativeDate object is a string that should be specified in one of 2 formats:

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.google.gwt.core.client.JavaScriptObject` | `getJsObj()`
    `RelativeDateRangePosition` | `getRangePosition()`
    `java.lang.String` | `getValue()`

    - ### Methods inherited from class com.smartgwt.client.core.DataClass

      `applyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, getReadOnly, isFactoryCreated, logConfiguration, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject, setFactoryCreated, setReadOnly`

    - ### Methods inherited from class com.smartgwt.client.core.JsObject

      `equals, hashCode, isCreated, setJavaScriptObject, setJsObj`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### NOW

          public static RelativeDate NOW

      Builtin option for this moment - equivalent to calling `new RelativeDate(RelativeDateShortcut.NOW);`

    - #### TODAY

          public static RelativeDate TODAY

      Builtin option for the start of today

    - #### START_OF_TODAY

          public static RelativeDate START_OF_TODAY

      Builtin option for the start of today (same as `TODAY`)

    - #### END_OF_TODAY

          public static RelativeDate END_OF_TODAY

      Builtin option for the end of today (one millisecond before the `START_OF_TODAY`

    - #### YESTERDAY

          public static RelativeDate YESTERDAY

      Builtin option for the start of yesterday

    - #### START_OF_YESTERDAY

          public static RelativeDate START_OF_YESTERDAY

      Builtin option for the start of yesterday (same as `YESTERDAY`)

    - #### END_OF_YESTERDAY

          public static RelativeDate END_OF_YESTERDAY

      Builtin option for the end of yesterday (one millisecond before the `START_OF_YESTERDAY`)

    - #### TOMORROW

          public static RelativeDate TOMORROW

      Builtin option for the start of tomorrow

    - #### START_OF_TOMORROW

          public static RelativeDate START_OF_TOMORROW

      Builtin option for the start of tomorrow (same as `TOMORROW`)

    - #### END_OF_TOMORROW

          public static RelativeDate END_OF_TOMORROW

      Builtin option for the end of tomorrow (one millisecond before the `START_OF_TOMORROW`)

    - #### WEEK_AGO

          public static RelativeDate WEEK_AGO

      Builtin option for the current day of the previous week

    - #### WEEK_FROM_NOW

          public static RelativeDate WEEK_FROM_NOW

      Builtin option for the current day of the following week

    - #### MONTH_AGO

          public static RelativeDate MONTH_AGO

      Builtin option for the current day of the previous month

    - #### MONTH_FROM_NOW

          public static RelativeDate MONTH_FROM_NOW

      Builtin option for the current day of the following month

    - #### START_OF_WEEK

          public static RelativeDate START_OF_WEEK

      Builtin option for the start of the current week

    - #### END_OF_WEEK

          public static RelativeDate END_OF_WEEK

      Builtin option for the end of the current week

    - #### START_OF_MONTH

          public static RelativeDate START_OF_MONTH

      Builtin option for this moment

    - #### END_OF_MONTH

          public static RelativeDate END_OF_MONTH

      Builtin option for the end of the current month

    - #### START_OF_YEAR

          public static RelativeDate START_OF_YEAR

      Builtin option for the start of the current year

    - #### END_OF_YEAR

          public static RelativeDate END_OF_YEAR

      Builtin option for the end of the current year

  - ### Constructor Detail

    - #### RelativeDate

          public RelativeDate(java.lang.String value)

      The value attribute of a RelativeDate object is a string that should be specified in one of 2 formats:

      There are a number of standard preset shortcut date-offset strings. These include the following

      - $now - this moment
      - $today - the current day. By default this resolves to the start of the current day though an explicit +link{RelativeDateRangePosition} may be used to specify the end of the current day.
      - $startOfToday - the start of today
      - $endOfToday - the end of today (one millisecond before the $startOfTomorrow)
      - $yesterday - the previous day.
      - $startOfYesterday - the start of yesterday
      - $endOfYesterday - the end of yesterday (one millisecond before the $startOfToday)
      - $tomorrow - the following day
      - $startOfTomorrow - the start of tomorrow
      - $endOfTomorrow - the end of tomorrow
      - $startOfWeek - the start of the current week
      - $endOfWeek - the end of the current week
      - $startOfMonth - the start of the current month
      - $endOfMonth - the end of the current month
      - $startOfYear - the start of the current year
      - $endOfYear - the end of the current year
      Note that some shortcuts indicate a time period but do not directly indicate whether the value refers to the start or end of the time period in question. This ambiguity can be resolved by specifying an explicit RelativeDateRangePosition when calling APIs that convert from RelativeDates to absolute date values. This is the case for $today, $tomorrow, $yesterday, $weekAgo, $weekFromNow, $monthAgo and $monthFromNow. If a range position is not explicitly passed, these will all default to the start of the day in question.

      Alternatively the value can be a special RelativeDateString comprised of the following parts:

      - direction: the direction in which the quantity applies - one of + or -
      - quantity: the number of units of time to apply - a number
      - timeUnit: an abbreviated timeUnit to use - one of ms/MS (millisecond), s/S (second), mn/MN (minute), h/H (hour), d/D (day), w/W (week), m/M (month), q/Q (quarter, 3-months), y/Y (year), dc/DC (decade) or c/C (century).
        The timeUnit is case sensitive. A lowercase timeUnit implies an exact offset, so `+1d` refers to the current date / time increased by exactly 24 hours. If the timeUnit is uppercase, it refers to the start or end boundary of the period of time in question, so `+1D` would refer to the end of the day (23:39:59:999) tomorrow, and `-1D` would refer to the start of the day (00:00:00:000) yesterday.
      - [qualifier]: an optional timeUnit encapsulated in square-brackets and used to offset the calculation - eg. if +1d is "plus one day", +1d[W] is "plus one day from the end of the current week". You may also specify another complete RelativeDateString as the [qualifier], which offers more control - eg, +1d[+1W] indicates "plus one day from the end of NEXT week".

      This format is very flexible. Here are a few example relative date strings:
      `+0D`: End of today. There are often multiple ways to represent the same time using this system - for example this could also be written as `-1ms[+1D]`
      `-0D`: Beginning of today.
      `+1W`: End of next week.
      `+1ms[+0W]`: Beginning of next week.
      `+1w[-0D]`: Beginning of the current day of next week.

      Parameters:
        `value` - string representation of the relative date

    - #### RelativeDate

          public RelativeDate(RelativeDateRangePosition rangePosition,
                              java.lang.String value)

    - #### RelativeDate

          public RelativeDate(com.google.gwt.core.client.JavaScriptObject jsObj)

  - ### Method Detail

    - #### getRangePosition

          public final RelativeDateRangePosition getRangePosition()

    - #### getValue

          public final java.lang.String getValue()

      Returns:
        the string representation of the relative date
      See Also:
        `RelativeDate(String)`

    - #### getJsObj

          public com.google.gwt.core.client.JavaScriptObject getJsObj()

      Overrides:
        `getJsObj` in class `JsObject`