LAST UPDATED: JUNE 15, 2020
Java LocalDate getChronology() Method
This method is used to get chronology of a date. Chronology is a term that refers to the calendar system in the modern world.
The ISO-8601 calendar system is the modern civil calendar system used today in most of the world.
This method returns IsoChronolgy that refers to the calendar system. The syntax of the method is given below.
Syntax
public IsoChronology getChronology()
Parameters:
It does not take any parameter.
Returns:
It returns ISO chronology.
Time for an Example:
Let's take an example where we will get chronology of a date using getChronology()
method. This example returns ISO chronology as a result.
import java.time.LocalDate;
import java.time.chrono.IsoChronology;
public class DateDemo {
public static void main(String[] args){
LocalDate localDate = LocalDate.of(2018, 2, 20);
System.out.println(localDate);
IsoChronology iso = localDate.getChronology();
System.out.println("date chronology : "+iso);
}
}
2018-02-20
date chronology : ISO
Time for another Example:
Here we have a string date which is then converted to localdate to fetch chronology. We can see that it display ISO chronology as a result.
import java.time.LocalDate;
import java.time.chrono.IsoChronology;
public class DateDemo {
public static void main(String[] args){
String date = "2015-02-06";
LocalDate localDate = LocalDate.parse(date);
System.out.println(localDate);
IsoChronology iso = localDate.getChronology();
System.out.println("date chronology : "+iso);
}
}
2015-02-06
date chronology : ISO
Live Example:
Try with a live example, execute the code instantly with our powerful Online Java Compiler.