Java Date Time - ZonedDateTime range(TemporalField field) example








ZonedDateTime 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.ZonedDateTime;
import java.time.temporal.ChronoField;
import java.time.temporal.ValueRange;
//  ww w .  j a  v  a 2  s .com
public class Main {
  public static void main(String[] args) {
    ZonedDateTime dateTime =ZonedDateTime.now();
    ValueRange l =dateTime.range(ChronoField.YEAR) ;
    System.out.println(l);
  } 
}

The code above generates the following result.