com.smartgwt.client.data
Class RelativeDate

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

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
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.JsObject
jsObj
 
Constructor Summary
RelativeDate(JavaScriptObject jsObj)
           
RelativeDate(RelativeDateRangePosition rangePosition, String value)
           
RelativeDate(String value)
          The value attribute of a RelativeDate object is a string that should be specified in one of 2 formats:
 
Method Summary
 JavaScriptObject getJsObj()
           
 RelativeDateRangePosition getRangePosition()
           
 String getValue()
           
 
Methods inherited from class com.smartgwt.client.core.DataClass
doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, 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
 
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(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

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:

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,
                    String value)

RelativeDate

public RelativeDate(JavaScriptObject jsObj)
Method Detail

getRangePosition

public final RelativeDateRangePosition getRangePosition()

getValue

public final String getValue()
Returns:
the string representation of the relative date
See Also:
RelativeDate(String)

getJsObj

public JavaScriptObject getJsObj()
Overrides:
getJsObj in class JsObject