ValueRange getMaximum() method in Java with Examples
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:
import java.time.LocalDateTime;
import java.time.temporal.ChronoField;
import java.time.temporal.ValueRange;
public class GFG {
public static void main(String[] args)
{
LocalDateTime l1
= LocalDateTime
.parse( "2018-12-06T19:21:12" );
ValueRange vR
= l1.range(ChronoField.DAY_OF_WEEK);
long maximum = vR.getMaximum();
System.out.println( "Maximum for DAY_OF_WEEK: "
+ maximum);
}
}
|
Output:
Maximum for DAY_OF_WEEK: 7
Program 2:
import java.time.temporal.ValueRange;
public class GFG {
public static void main(String[] args)
{
ValueRange vRange = ValueRange.of( 1111 , 99999 );
long max = vRange.getMaximum();
System.out.println( "Maximum : "
+ max);
}
}
|
References: https://docs.oracle.com/javase/10/docs/api/java/time/temporal/ValueRange.html#getMaximum()
Last Updated :
29 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...