Japanese Era Dates Via Chronology
JapaneseDate and ThaiBuddhistDate express the same LocalDate in era-based calendars, and convert straight back through getChronology.
Code
import java.time.LocalDate;
import java.time.chrono.JapaneseDate;
import java.time.chrono.ThaiBuddhistDate;
import java.time.temporal.ChronoField;
public class EraCalendars {
public static void main(String[] args) {
LocalDate iso = LocalDate.of(2026, 11, 19);
JapaneseDate reiwa = JapaneseDate.from(iso);
ThaiBuddhistDate buddhist = ThaiBuddhistDate.from(iso);
// 同一天在不同历法下的表达:和历年号 + 佛历年份
System.out.println("iso : " + iso);
System.out.println("japanese : " + reiwa);
System.out.println("era : " + reiwa.getEra());
System.out.println("yearOfEra : " + reiwa.get(ChronoField.YEAR_OF_ERA));
System.out.println("buddhist : " + buddhist);
// 历法对象可从日期反查,再转回 ISO
System.out.println("chrono : " + reiwa.getChronology().getId());
System.out.println("back : " + LocalDate.from(reiwa));
}
}One LocalDate, three calendars
LocalDate.of(2026, 11, 19) is the single source of truth; JapaneseDate.from(iso) and ThaiBuddhistDate.from(iso) re-express the same day in era-based chronologies without any manual year arithmetic. The Japanese view resolves to the Reiwa era, so reiwa.get(ChronoField.YEAR_OF_ERA) reads the year within Reiwa, and reiwa.getEra() returns the era constant itself. The Buddhist view is a simple year offset (+543).
What the run prints
iso : 2026-11-19
japanese : Japanese Reiwa 8-11-19
era : Reiwa
yearOfEra : 8
buddhist : BE 2569-11-19
chrono : Japanese
back : 2026-11-19
reiwa.getChronology().getId() names the chronology behind the date object, and LocalDate.from(reiwa) converts straight back to the ISO date — the round trip the closing comment describes (query the chronology, convert back to ISO) closes with the original value.
The line that re-expresses the day
JapaneseDate reiwa = JapaneseDate.from(iso);
The from conversion carries all era logic internally; call sites never compute era boundaries themselves, which is what makes era changes (Reiwa began mid-2019) safe to consume.
Interactive Tools for This Topic
FAQ
- What does Japanese Era Dates Via Chronology print when run?
- Running the file directly is enough — expect labeled output lines such as `iso :`, `japanese :`, `era :`.
Report a problem with this exampleOpens a pre-filled issue on GitHub.