OffsetTime isSupported(TemporalField field) example

Description

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

The supported fields are:


NANO_OF_SECOND /*from w w  w . j a va  2 s .com*/
NANO_OF_DAY 
MICRO_OF_SECOND 
MICRO_OF_DAY 
MILLI_OF_SECOND 
MILLI_OF_DAY 
SECOND_OF_MINUTE 
SECOND_OF_DAY 
MINUTE_OF_HOUR 
MINUTE_OF_DAY 
HOUR_OF_AMPM 
CLOCK_HOUR_OF_AMPM 
HOUR_OF_DAY 
CLOCK_HOUR_OF_DAY 
AMPM_OF_DAY 
OFFSET_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.OffsetTime;
import java.time.temporal.ChronoField;
//from   w ww  .  j  av a 2  s .c  om
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    boolean z = m.isSupported(ChronoField.HOUR_OF_DAY);
    System.out.println(z);

  }
}

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