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.
Static
Readonly
NANOS_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.
Optional
timeZone: TimeZoneString
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.
Optional
tz: TimeZoneStatic
formatAccepts 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.
Optional
timeZone: TimeZoneStatic
geta 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.
Static
parseParses 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.
Optional
tz: TimeZoneStatic
parse
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 JSNumber
there is likely to be some loss of precision, though this is still supported for easier interoperability with other JS code. The values returned byparse()
will be an opaque object wrapping the full precision of the specified date, However, this object supportstoString()
andvalueOf()
to return a string representation of that value, as well as aasNumber()
to return a JSNumber
value and aasDate()
to return a JSDate
value.Caveats:
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, thoughz
will work as expected in the browser to emit the user's own timezone.