Java Date Time - DayOfWeek isSupported(TemporalField field) example








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

Syntax

isSupported has the following syntax.

public boolean isSupported(TemporalField field)

Example

The following example shows how to use isSupported.

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
import java.time.temporal.ChronoField;
/*  w  w  w. java2 s  .  c o m*/
public class Main {
  public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, Month.JUNE, 21);
    DayOfWeek dayOfWeek = DayOfWeek.from(localDate);
    System.out.println(dayOfWeek.isSupported(ChronoField.DAY_OF_YEAR));
  }
}

The code above generates the following result.