VOOZH about

URL: https://www.geeksforgeeks.org/java/year-issupportedtemporalfield-method-in-java-with-examples/

⇱ Year isSupported(TemporalField) Method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Year isSupported(TemporalField) Method in Java with Examples

Last Updated : 1 May, 2023

The isSupported(TemporalField) method of Year class is used to check if the specified field is supported by Year class or not means using this method we can check if this Year object can be queried for the specified field.

The supported fields of ChronoField are: 

  • YEAR_OF_ERA
  • YEAR
  • ERA

All other ChronoField instances will return false.

Syntax:  

public boolean isSupported(TemporalField field)

Parameters: Field which represents the field to check.
Return Value: Boolean value true if the field is supported on this Year, false if not.

Below programs illustrate the isSupported(TemporalField) method:

Program 1:  

Output

Year :2019
YEAR_OF_ERA Field is supported by Year class: true

Program 2A: 


Output
Year :2022
MilliSecond Field is supported: false

Program 2B:

Output:

Is year supported? true
Is day of week supported? true 
Comment
Article Tags: