HijrahDate getEra() method in Java with Example
The getEra() method of java.time.chrono.HijrahDate class is used to retrieve the era related to this hijrah date.
Syntax:
public HijrahEra getEra()
Parameter: This method does not accept any parameter.
Return Value: This method returns the era of this hijrah date.
Below are the examples to illustrate the getEra() method:
Example 1:
Java
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
public class GFG {
public static void main(String[] argv)
{
try {
HijrahDate hidate = HijrahDate.now();
HijrahEra crono = hidate.getEra();
System.out.println( "HijrahEra: "
+ crono);
}
catch (DateTimeException e) {
System.out.println( "passed parameter can"
+ " not form a date" );
System.out.println( "Exception thrown: "
+ e);
}
}
}
|
Example 2:
Java
import java.util.*;
import java.io.*;
import java.time.*;
import java.time.chrono.*;
public class GFG {
public static void main(String[] argv) {
try {
HijrahDate hidate
= HijrahDate.of( 1444 , 04 , 24 );
HijrahEra crono = hidate.getEra();
System.out.println( "HijrahEra : "
+ crono);
} catch (DateTimeException e) {
System.out.println( "passed parameter can"
+ " not form a date" );
System.out.println( "Exception thrown: " + e);
}
}
}
|
Reference: https://docs.oracle.com/javase/9/docs/api/java/time/chrono/HijrahDate.html#getEra–
Last Updated :
23 Jan, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...