Java - Non-ISO Calendar Systems

Introduction

The non-ISO calendar-related classes are in the java.time.chrono package.

XxxChronology class represents the Xxx calendar system whereas XxxDate class represents a date in the Xxx calendar system.

Each XxxChronology class contains an INSTANCE constant that represents a singleton instance of that class.

The following code shows two ways to get the current date in the Thai Buddhist calendar:

Demo

import java.time.chrono.ThaiBuddhistChronology;
import java.time.chrono.ThaiBuddhistDate;

public class Main {
  public static void main(String[] args) {
    ThaiBuddhistChronology thaiBuddhistChrono = ThaiBuddhistChronology.INSTANCE;
    ThaiBuddhistDate now = thaiBuddhistChrono.dateNow();
    ThaiBuddhistDate now2 = ThaiBuddhistDate.now();
    System.out.println("Current Date in Thai Buddhist: " + now);
    System.out.println("Current Date in Thai Buddhist: " + now2);
  }/*  w ww.  j  a v a  2 s  .  co  m*/
}

Result

Related Topics