ValueRange getMaximum() method in Java with Examples

Last Updated : 29 Jan, 2020
The getMaximum() method of ValueRange class is used to get the maximum value that the ValueRange can take. For example, the ChronoField DAY_OF_WEEK always ends at 7. The maximum is, therefore 7. Syntax:
public long getMaximum()
Parameters: This method accepts nothing. Return value: This method returns the maximum value for this valueRange. Below programs illustrate the ValueRange.getMaximum() method: Program 1: Java
// Java program to demonstrate
// ValueRange.getMaximum() method

import java.time.LocalDateTime;
import java.time.temporal.ChronoField;
import java.time.temporal.ValueRange;

public class GFG {
    public static void main(String[] args)
    {

        // create LocalDateTime
        LocalDateTime l1
            = LocalDateTime
                  .parse("2018-12-06T19:21:12");

        // Get ValueRange object
        ValueRange vR
            = l1.range(ChronoField.DAY_OF_WEEK);

        // apply getMaximum()
        long maximum = vR.getMaximum();

        // print results
        System.out.println("Maximum for DAY_OF_WEEK: "
                           + maximum);
    }
}
Output:
Maximum for DAY_OF_WEEK: 7
Program 2: Java
// Java program to demonstrate
// ValueRange.getMaximum() method

import java.time.temporal.ValueRange;

public class GFG {
    public static void main(String[] args)
    {

        // create ValueRange object
        ValueRange vRange = ValueRange.of(1111, 99999);

        // get Maximum value using getMaximum()
        long max = vRange.getMaximum();

        // print results
        System.out.println("Maximum : "
                           + max);
    }
}
Comment