Package com.emc.documentum.rest.format.date

# Class DateFormatter

java.lang.Object
com.emc.documentum.rest.format.date.DateFormatter

public final class DateFormatter extends Object
This class is used for formatting/parsing date time according to ISO 8601. We allow any ISO 8601 compliant date to be used as input for our service, and will format all outgoing dates according to RFC 3339, which is a profile of ISO 8601 This class is thread safe.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `GMT_ID`
  `static final org.joda.time.format.DateTimeFormatter`
  `ISO_8601_DATE_PARSER`
  `static final String`
  `PATTERN_RFC_3339`
  `static final org.joda.time.format.DateTimeFormatter`
  `RFC_3339_FORMATTER`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `now()`
  Return a RFC 3339 date string representing the current time
  `static Date`
  `parse(String date)`
  Parse an ISO 8601 compliant date string into a Date object If a date without time zone offset is provided, time zone UTC (offset zero) will be assumed instead of local time zone.
  `static Date`
  `parse(String date, String timeZoneStr)`
  Parse a ISO 8601 compliant date string into a Date object If a date without time zone offset is provided, time zone specified by `timeZoneStr` will be assumed instead of local time zone.
  `static String`
  `print(Date date)`
  Server will format the date time according to RFC 3339, http://tools.ietf.org/html/rfc3339#page-8 Atom syndication format requires date to be formatted with RFC 3339 According to RFC 3339, a colon will be used as delimiter in time zone offset `time-numoffset = ("+" / "-") time-hour ":" time-minute`
  `static String`
  `print(Date date, String timeZoneStr)`
  Server will format the date time based on `timeZoneStr` according to RFC 3339, http://tools.ietf.org/html/rfc3339#page-8.
  `static String`
  `print(Date date, String timeZoneStr, String pattern)`
  Server will format the date time based on `timeZoneStr` and `pattern` complying with http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html.
  `static Date`
  `tryParse(String date)`
  Try to parse an ISO 8601 compliant date string into a Date object If a date without time zone offset is provided, time zone UTC (offset zero) will be assumed instead of local time zone.

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

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

- ## Field Details

  - ### GMT_ID

    public static final String GMT_ID

  - ### PATTERN_RFC_3339

    public static final String PATTERN_RFC_3339
    See Also:
      - Constant Field Values

  - ### ISO_8601_DATE_PARSER

    public static final org.joda.time.format.DateTimeFormatter ISO_8601_DATE_PARSER

  - ### RFC_3339_FORMATTER

    public static final org.joda.time.format.DateTimeFormatter RFC_3339_FORMATTER

- ## Method Details

  - ### print

    public static String print(Date date)
    Server will format the date time according to RFC 3339, http://tools.ietf.org/html/rfc3339#page-8 Atom syndication format requires date to be formatted with RFC 3339 According to RFC 3339, a colon will be used as delimiter in time zone offset `time-numoffset = ("+" / "-") time-hour ":" time-minute`
    Parameters:
      `date` - a Date instance
    Returns:
      null if the date is null, otherwise a string compliant with RFC 3339 for the provided date

  - ### print

    public static String print(Date date, String timeZoneStr)
    Server will format the date time based on `timeZoneStr` according to RFC 3339, http://tools.ietf.org/html/rfc3339#page-8. Atom syndication format requires date to be formatted with RFC 3339 According to RFC 3339, a colon will be used as delimiter in time zone offset `time-numoffset = ("+" / "-") time-hour ":" time-minute` Here is a sample. `DateFormatter.print(date, "Europe/Paris");` date is 2015-09-04T02:43:03.118+08:00 The output is "2015-09-03T20:43:03.118+02:00"
    Parameters:
      `date` - a Date instance
      `timeZoneStr` - time zone string. If it is invalid, UTC will be adopted.
    Returns:
      null if the date is null, otherwise a string compliant with RFC 3339 for the provided date

  - ### print

    public static String print(Date date, String timeZoneStr, String pattern)
    Server will format the date time based on `timeZoneStr` and `pattern` complying with http://joda-time.sourceforge.net/apidocs/org/joda/time/format/DateTimeFormat.html. The format is not limited to RFC 3339 E.G., time zone offset can be in such formats: -0800; -08:00; America/Los_Angeles Here is a sample. `DateFormatter.print(date, "Europe/Paris", "yyyy-MM-dd'T'HH:mm:ss.SSSZ");` date is 2015-09-04T02:43:03.118+08:00 The output is "2015-09-03T20:43:03.118+0200"
    Parameters:
      `date` - a Date instance
      `timeZoneStr` - time zone string. If it is invalid, UTC will be adopted.
      `pattern` - the date format pattern supported by `DateTimeFormat`, not limited to RFC 3339
    Returns:
      null if the date is null, otherwise a string compliant with RFC 3339 for the provided date

  - ### now

    public static String now()
    Return a RFC 3339 date string representing the current time
    Returns:
      a RFC 3339 date string representing the current time

  - ### parse

    public static Date parse(String date)
    Parse an ISO 8601 compliant date string into a Date object If a date without time zone offset is provided, time zone UTC (offset zero) will be assumed instead of local time zone.
    Parameters:
      `date` - a string that is compliant with ISO 8601
    Returns:
      a Date object parsed from the date string provided

  - ### tryParse

    public static Date tryParse(String date)
    Try to parse an ISO 8601 compliant date string into a Date object If a date without time zone offset is provided, time zone UTC (offset zero) will be assumed instead of local time zone. If date format is not ISO 8601, or fail to parse, the current date will be returned.
    Parameters:
      `date` - a string that is compliant with ISO 8601
    Returns:
      a Date object parsed from the date string provided

  - ### parse

    public static Date parse(String date, String timeZoneStr)
    Parse a ISO 8601 compliant date string into a Date object If a date without time zone offset is provided, time zone specified by `timeZoneStr` will be assumed instead of local time zone. Here are two samples. `DateFormatter.parse("2015-09-04T02:43:03.118+05:00", "GMT+3");` The output is 2015-09-04T02:43:03.118+05:00 `DateFormatter.parse("2015-09-04T02:43:03.118", "GMT+3");` The output is 2015-09-04T02:43:03.118+03:00
    Parameters:
      `date` - a string that is compliant with ISO 8601
      `timeZoneStr` - time zone string. If it is invalid, UTC will be adopted.
    Returns:
      a Date object parsed from the date string provided