다음을 통해 공유


DateTimeFormatter.ParsedLeapSecond Method

Definition

A query that provides access to whether a leap-second was parsed.

[Android.Runtime.Register("parsedLeapSecond", "()Ljava/time/temporal/TemporalQuery;", "", ApiSince=26)]
public static Java.Time.Temporal.ITemporalQuery? ParsedLeapSecond ();
[<Android.Runtime.Register("parsedLeapSecond", "()Ljava/time/temporal/TemporalQuery;", "", ApiSince=26)>]
static member ParsedLeapSecond : unit -> Java.Time.Temporal.ITemporalQuery

Returns

a query that provides access to whether a leap-second was parsed

Attributes

Remarks

A query that provides access to whether a leap-second was parsed.

This returns a singleton TemporalQuery query that provides access to additional information from the parse. The query always returns a non-null boolean, true if parsing saw a leap-second, false if not.

Instant parsing handles the special "leap second" time of '23:59:60'. Leap seconds occur at '23:59:60' in the UTC time-zone, but at other local times in different time-zones. To avoid this potential ambiguity, the handling of leap-seconds is limited to DateTimeFormatterBuilder#appendInstant(), as that method always parses the instant with the UTC zone offset.

If the time '23:59:60' is received, then a simple conversion is applied, replacing the second-of-minute of 60 with 59. This query can be used on the parse result to determine if the leap-second adjustment was made. The query will return true if it did adjust to remove the leap-second, and false if not. Note that applying a leap-second smoothing mechanism, such as UTC-SLS, is the responsibility of the application, as follows:

TemporalAccessor parsed = formatter.parse(str);
             Instant instant = parsed.query(Instant::from);
             if (parsed.query(DateTimeFormatter.parsedLeapSecond())) {
               // validate leap-second is correct and apply correct smoothing
             }

Java documentation for java.time.format.DateTimeFormatter.parsedLeapSecond().

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