Sdílet prostřednictvím


DateTimeFormatter.IsoInstant Property

Definition

The ISO instant formatter that formats or parses an instant in UTC, such as '2011-12-03T10:15:30Z'.

[Android.Runtime.Register("ISO_INSTANT", ApiSince=26)]
public static Java.Time.Format.DateTimeFormatter? IsoInstant { get; }
[<Android.Runtime.Register("ISO_INSTANT", ApiSince=26)>]
static member IsoInstant : Java.Time.Format.DateTimeFormatter

Property Value

Attributes

Remarks

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 instant will always be suffixed by 'Z' to indicate UTC. The second-of-minute is always output. The nano-of-second outputs zero, three, six or nine digits as necessary. When parsing, the behaviour of DateTimeFormatterBuilder#appendOffsetId() will be used to parse the offset, converting the instant to UTC as necessary. The 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: <ul> <li>The #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. </ul>

The returned formatter has no override chronology or zone. It uses the ResolverStyle#STRICT STRICT resolver style.

Java documentation for java.time.format.DateTimeFormatter.ISO_INSTANT.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to