Java - Convert dates in one calendar system to another.


ISO dates to non-ISO dates conversion is allowed.

The following code shows how to convert ISO date to Thai Buddhist date and vice versa.


import java.time.LocalDate;
import java.time.chrono.ThaiBuddhistDate;

public class Main {
  public static void main(String[] args) {
    ThaiBuddhistDate thaiBuddhistNow =;
    LocalDate isoNow =;
    System.out.println("Thai Buddhist Current Date: " + thaiBuddhistNow);
    System.out.println("ISO Current Date: " + isoNow);
    // Convert Thai Buddhist date to ISO date and vice versa
    ThaiBuddhistDate thaiBuddhistNow2 = ThaiBuddhistDate.from(isoNow);
    LocalDate isoNow2 = LocalDate.from(thaiBuddhistNow);
    System.out.println("Thai Buddhist Current Date from ISO: "
        + thaiBuddhistNow2);//from www  . ja v a 2s . c o  m
    System.out.println("ISO Current Date from Thai Buddhist: " + isoNow2);


Related Topic