Java ThaiBuddhistChronology from LocalDate

Description

Java ThaiBuddhistChronology from LocalDate

import java.time.LocalDate;
import java.time.Month;
import java.time.chrono.ChronoLocalDate;
import java.time.chrono.Chronology;
import java.time.chrono.ThaiBuddhistChronology;
import java.time.format.DateTimeFormatter;

public class Main {
  public static String toString(LocalDate localDate, Chronology chrono) {
    ChronoLocalDate cDate;//from w  ww.  j  a  v  a2  s.co m
    cDate = chrono.date(localDate);
    String pattern = "M/d/yyyy GGGGG";
    DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(pattern);
    return dateFormatter.format(cDate);
  }

  public static void main(String[] args) {
    LocalDate date = LocalDate.of(2020, Month.OCTOBER, 29);
    System.out.printf("%s%n", toString(date, ThaiBuddhistChronology.INSTANCE));

  }
}



PreviousNext

Related