Instant
objects can be serialized and parsed using the RFC 9557 format, an extension to the ISO 8601 / RFC 3339 format. The string has the following form (spaces are only for readability and should not be present in the actual string):
YYYY-MM-DD T HH:mm:ss.sssssssss Z/±HH:mm:ss.sssssssss
YYYY
-
Either a four-digit number, or a six-digit number with a +
or -
sign.
MM
-
A two-digit number from 01
to 12
.
DD
-
A two-digit number from 01
to 31
. The YYYY
, MM
, and DD
components can be separated by -
or nothing.
T
-
The date-time separator, which can be T
, t
, or a space.
HH
-
A two-digit number from 00
to 23
.
mm
Optional -
A two-digit number from 00
to 59
. Defaults to 00
.
ss.sssssssss
Optional -
A two-digit number from 00
to 59
. May optionally be followed by a .
or ,
and one to nine digits. Defaults to 00
. The HH
, mm
, and ss
components can be separated by :
or nothing. You can omit either just ss
or both ss
and mm
, so the time can be one of three forms: HH
, HH:mm
, or HH:mm:ss.sssssssss
.
Z/±HH:mm:ss.sssssssss
-
Either the UTC designator Z
or z
, or an offset from UTC in the form +
or -
followed by the same format as the time component. Note that subminute precision may be unsupported by other systems. If an offset is provided, the time is interpreted in the specified offset.
As an input, you may optionally include the time zone identifier and calendar, in the same format as ZonedDateTime
, but they will be ignored. Other annotations in the [key=value]
format are also ignored, and they must not have the critical flag.
When serializing, you can configure the fractional second digits and offset.