Java Date Time - LocalDateTime range(TemporalField field) example








LocalDateTime 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.LocalDateTime;
import java.time.temporal.ChronoField;
/*  ww  w. j a va  2  s  .  c om*/
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 01);
    
    System.out.println(a.range(ChronoField.DAY_OF_WEEK));
  }
}

The code above generates the following result.