Java JapaneseChronology from LocalDate

Description

Java JapaneseChronology from LocalDate

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

public class Main {
  public static String toString(LocalDate localDate, Chronology chrono) {
    ChronoLocalDate cDate;//from   www. jav a2s .  c om
    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, JapaneseChronology.INSTANCE));

  }
}



PreviousNext

Related