The ISO instant formatter that formats or parses an instant in UTC, such as '2011-12-03T10:15:30Z'.
This returns an immutable formatter capable of formatting and parsing the ISO-8601 instant format. When formatting, the second-of-minute is always output. The nano-of-second outputs zero, three, six or nine digits as necessary. When parsing, time to at least the seconds field is required. Fractional seconds from zero to nine are parsed. The localized decimal style is not used.
This is a special case formatter intended to allow a human readable form
of an java.time.Instant
. The Instant
class is designed to
only represent a point in time and internally stores a value in nanoseconds
from a fixed epoch of 1970-01-01Z. As such, an Instant
cannot be
formatted as a date or time without providing some form of time-zone.
This formatter allows the Instant
to be formatted, by providing
a suitable conversion using ZoneOffset.UTC
.
The format consists of:
ISO_OFFSET_DATE_TIME
where the instant is converted from
ChronoField.INSTANT_SECONDS
and ChronoField.NANO_OF_SECOND
using the UTC
offset. Parsing is case insensitive.
The returned formatter has no override chronology or zone.
It uses the STRICT
resolver style.
Diagram: Format