Instant isSupported(TemporalField field) example

Description

Instant isSupported(TemporalField field) checks if the specified field is supported.

The supported fields are: NANO_OF_SECOND MICRO_OF_SECOND MILLI_OF_SECOND INSTANT_SECONDS. All other ChronoField instances will return false.

Syntax

isSupported has the following syntax.


public boolean isSupported(TemporalField field)

Example

The following example shows how to use isSupported.


import java.time.Instant;
import java.time.temporal.ChronoField;
//from w  w  w .j a  va2  s. co m
public class Main {
  public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    System.out.println(instant.isSupported(ChronoField.YEAR));
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset