java.time.Year.isSupported() Method Example



Description

The java.time.Year.isSupported(TemporalField field) method checks if the specified field is supported.

Declaration

Following is the declaration for java.time.Year.isSupported(TemporalField field) method.

public boolean isSupported(TemporalField field)

Parameters

field − the field to check, null returns false.

Return Value

true if the field is supported on this date, false if not.

Example

The following example shows the usage of java.time.Year.isSupported(TemporalField field) method.

package com.tutorialspoint;

import java.time.Year;
import java.time.temporal.ChronoField;

public class YearDemo {
   public static void main(String[] args) {
 
      Year date = Year.of(2020);
      System.out.println(date.isSupported(ChronoField.ERA));  
   }
}

Let us compile and run the above program, this will produce the following result −

true
Advertisements