ChronoPeriod getChronology() method in Java with Examples
Last Updated :
24 Jun, 2019
The getChronology() method of ChronoPeriod interface in Java is used to get the chronology of this Period, which is the ISO calendar system.
Syntax:
ChronoPeriod getChronology()
Parameters: This method does not accepts any parameter.
Return Value: This method returns String representation of this
Below program illustrates the above method:
Program 1:
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.ChronoUnit;
public class ChronoPeriodClass {
static void printChronology(ChronoPeriod p1)
{
System.out.println(p1.getChronology());
}
public static void main(String[] args)
{
int year = 4 ;
int months = 11 ;
int days = 10 ;
ChronoPeriod p1 = Period.of(year, months, days);
printChronology(p1);
}
}
|
Program 2:
import java.time.*;
import java.time.chrono.*;
import java.time.temporal.ChronoUnit;
public class ChronoPeriodClass {
static void printChronology(ChronoPeriod p1)
{
System.out.println(p1.getChronology());
}
public static void main(String[] args)
{
int year = - 4 ;
int months = - 11 ;
int days = - 10 ;
ChronoPeriod p1 = Period.of(year, months, days);
printChronology(p1);
}
}
|
Reference: https://docs.oracle.com/javase/9/docs/api/java/time/chrono/ChronoPeriod.html#getChronology–
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...