Java Date Time - Instant range(TemporalField field) example








Instant 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.Instant;
import java.time.temporal.ChronoField;
//from   www  . j a  v a  2  s . c  om
public class Main {
  public static void main(String[] args) {
    Instant instant = Instant.parse("2014-12-03T10:15:30.00Z");
    System.out.println(instant.range(ChronoField.NANO_OF_SECOND));
    
  }
}

The code above generates the following result.