Java Date Time - Year range(TemporalField field) example








Year range(TemporalField field) gets the range of valid values for the specified field.

Syntax

range has the following syntax.

public ValueRange range(TemporalField field)

Example

The following example shows how to use range.

import java.time.Year;
import java.time.temporal.ChronoField;
//from   ww  w .j  a  v  a2s .co  m
public class Main {
  public static void main(String[] args) {
    Year y = Year.of(2014);
    
    System.out.println(y.range(ChronoField.YEAR));

  }
}

The code above generates the following result.