Largely an exported wrapper for the GWT DateFormat, but also includes support for formatting nanoseconds as an additional 6 decimal places after the rest of the number.

Other concerns that this handles includes accepting a js Date and ignoring the lack of nanos, accepting a js Number and assuming it to be a lossy nano value, and parsing into a js Date.

Utility class to parse and format various date/time values, using the same format patterns as are supported by the standard Java implementation used in the Deephaven server and swing client.

As Deephaven internally uses nanosecond precision to record dates, this API expects nanoseconds in most use cases, with the one exception of the JS Date type, which is not capable of more precision than milliseconds. Note, however, that when passing nanoseconds as a JS Number there is likely to be some loss of precision, though this is still supported for easier interoperability with other JS code. The values returned by parse() will be an opaque object wrapping the full precision of the specified date, However, this object supports toString() and valueOf() to return a string representation of that value, as well as a asNumber() to return a JS Number value and a asDate() to return a JS Date value.

Caveats:

  • The D format (for "day of year") is not supported by this implementation at this time. - The %t format for short timezone code is not supported by this implementation at this time, though z will work as expected in the browser to emit the user's own timezone.

Hierarchy

  • DateTimeFormat

Constructors

  • Creates a new date/time format instance. This generally should be avoided in favor of the static getFormat function, which will create and cache an instance so that later calls share the same instance.

    Parameters

    • pattern: string

    Returns DateTimeFormat

Properties

NANOS_PER_MILLI: number

Methods

  • Takes a variety of objects to interpret as a date, and formats them using this instance's pattern. Inputs can include a String value of a number expressed in nanoseconds, a Number value expressed in nanoseconds, a JS Date object (necessarily in milliseconds), or a wrapped Java long value, expressed in nanoseconds. A TimeZone object can optionally be provided to format this date as the current date/time in that timezone.

    Parameters

    Returns string

    String

  • Parses the given string using this instance's pattern, and returns a wrapped Java long value in nanoseconds. A TimeZone object can optionally be provided to parse to a desired timezone.

    Parameters

    Returns DateWrapper

  • Parses the given string using this instance's pattern, and returns a JS Date object in milliseconds.

    Parameters

    • text: string

    Returns Date

  • Returns string

  • Accepts a variety of input objects to interpret as a date, and formats them using the specified pattern. A TimeZone object can optionally be provided to format this date as the current date/time in that timezone.See the instance method for more details on input objects.

    Parameters

    • pattern: string
    • date: any
    • Optional timeZone: TimeZone

    Returns string

  • Parameters

    • pattern: string

    Returns DateTimeFormat

    a date format instance matching the specified format. If this format has not been specified before, a new instance will be created and stored for later reuse.

  • Parses the given input string using the provided pattern, and returns a wrapped Java long value in nanoseconds. A TimeZone object can optionally be provided to parse to a desired timezone.

    Parameters

    • pattern: string
    • text: string
    • Optional tz: TimeZone

    Returns DateWrapper

  • Parses the given input string using the provided pattern, and returns a JS Date object in milliseconds.

    Parameters

    • pattern: string
    • text: string

    Returns Date