Java Date Time - MonthDay isSupported(TemporalField field) example








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

The supported fields are: MONTH_OF_YEAR and YEAR. 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.MonthDay;
import java.time.temporal.ChronoField;
/* www .  j av  a  2  s  .  c om*/
public class Main {
  public static void main(String[] args) {
    MonthDay m = MonthDay.now();
    boolean n = m.isSupported(ChronoField.MONTH_OF_YEAR);
    System.out.println(n);

  }
}

The code above generates the following result.