Java Date Time - YearMonth isSupported(TemporalField field) example








YearMonth 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.YearMonth;
import java.time.temporal.ChronoField;
/*from  w  ww . j a v  a  2s .  c  o  m*/
public class Main {
  public static void main(String[] args) {
    YearMonth y = YearMonth.now();
    boolean m = y.isSupported(ChronoField.YEAR);
    System.out.println(m);

  }
}

The code above generates the following result.