Java Date Time Java Java API
Class:
java.time.temporal.ValueRange
Methods:
public static ValueRange of(long min,
long max)
Obtains a fixed value range. Useful when range has the minimum and maximum values fixed. For example, the ISO month-of-year always runs from 1 to 12.
- Parameters:
min - the minimum valuemax - the maximum value- Returns:
- the ValueRange for min, max, not null
- Throws:
IllegalArgumentException - if the minimum is greater than the maximum
public static ValueRange of(long min,
long maxSmallest,
long maxLargest)
Obtains a variable value range. Useful when range has the minimum value fixed but the maximum value may vary. For example, the ISO day-of-month always starts at 1, but ends between 28 and 31.
- Parameters:
min - the minimum valuemaxSmallest - the smallest maximum valuemaxLargest - the largest maximum value- Returns:
- the ValueRange for min, smallest max, largest max, not null
- Throws:
IllegalArgumentException - if the minimum is greater than the smallest maximum, or the smallest maximum is greater than the largest maximum
public static ValueRange of(long minSmallest,
long minLargest,
long maxSmallest,
long maxLargest)
Obtains a fully variable value range. Useful when both the minimum and maximum value may vary.
- Parameters:
minSmallest - the smallest minimum valueminLargest - the largest minimum valuemaxSmallest - the smallest maximum valuemaxLargest - the largest maximum value- Returns:
- the ValueRange for smallest min, largest min, smallest max, largest max, not null
-
Throws:
IllegalArgumentException - if the smallest minimum is greater than the smallest maximum, or the smallest maximum is greater than the largest maximum or the largest minimum is greater than the largest maximum
Examples
package com.logicbig.example.valuerange;
import java.time.temporal.ValueRange;
public class OfExample {
public static void main(String... args) { ValueRange valueRange = ValueRange.of(10, 30); System.out.println(valueRange); } }
Output10 - 30
package com.logicbig.example.valuerange;
import java.time.temporal.ValueRange;
public class OfExample2 {
public static void main(String... args) { ValueRange valueRange = ValueRange.of(10, 30, 35); System.out.println(valueRange); } }
Output10 - 30/35
package com.logicbig.example.valuerange;
import java.time.temporal.ValueRange;
public class OfExample3 {
public static void main(String... args) { ValueRange valueRange = ValueRange.of(10, 18, 67, 90); System.out.println(valueRange); } }
Output10/18 - 67/90
|
|