The range() method of java.time.chrono.HijrahChronology class is used get the range from the specified field of type chrono.
Syntax:
public ValueRange range(ChronoField field)
Parameter: This method takes the field of type ChronoField as a parameter.
Return Value: This method returns range from the specified field of type chrono.
Below are the examples to illustrate the range() method:
Example 1:
Java
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.*;
public class GFG {
public static void main(String[] argv) {
try {
HijrahDate hidate = HijrahDate.now();
HijrahChronology crono = hidate.getChronology();
ValueRange range = crono.range(ChronoField.ERA);
System.out.println( "Equivalent Range : " + range);
} catch (DateTimeException e) {
System.out.println( "passed parameter can"
+ " not form a date" );
System.out.println( "Exception thrown: " + e);
}
}
}
|
Output
Equivalent Range : 1 - 1
Example 2:
Java
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.*;
public class GFG {
public static void main(String[] argv) {
try {
HijrahDate hidate = HijrahDate.now();
HijrahChronology crono = hidate.getChronology();
ValueRange range = crono.range(ChronoField.YEAR);
System.out.println( "Equivalent Range : " + range);
} catch (DateTimeException e) {
System.out.println( "passed parameter can"
+ " not form a date" );
System.out.println( "Exception thrown: " + e);
}
}
}
|
Output
Equivalent Range : 1300 - 1600
Reference: https://docs.oracle.com/javase/9/docs/api/java/time/chrono/HijrahChronology.html#range-java.time.temporal.ChronoField-
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
20 Jan, 2023
Like Article
Save Article