年号が変わったらJavaのCalendarの和暦変換はどうなるのか
と仕事中にふと思った。
コードを探してみたらあった。
クラスについて
JapaneseImperialCalendar
implements a Japanese calendar system in which the imperial era-based year numbering is supported from the Meiji era. The following are the eras supported by this calendar system.
年号ベースで番号付けしてる日本のカレンダーを実装してますって書いてありますね。明治より前は登録されていないようです。生年月日での用途が主だからということでしょうかね。
年代(Era)クラス
1 2 3 4 5 6 7 |
public final class More Era { private final String name; private final String abbr; private final long since; private final CalendarDate sinceDate; private final boolean localTime; } |
日本以外にも国独自の表記ってあるんだなー。
The class
Era
represents a calendar era that defines a period of time in which the same year numbering is used. For example, Gregorian year 2004 is Heisei 16 in the Japanese calendar system. An era starts at any point of time (Gregorian) that is represented byCalendarDate
.
Era
s that are applicable to a particular calendar system can be obtained by callingCalendarSystem.getEras()
one of which can be used to specify a date inCalendarDate
.The following era names are defined in this release.
123456789101112 <tt>Calendar system Era name Since (in Gregorian)-----------------------------------------------------------------------Japanese calendar Meiji 1868-01-01 midnight local timeTaisho 1912-07-30 midnight local timeShowa 1926-12-26 midnight local timeHeisei 1989-01-08 midnight local timeJulian calendar BeforeCommonEra -292275055-05-16T16:47:04.192ZCommonEra 0000-12-30 midnight local timeTaiwanese calendar MinGuo 1911-01-01 midnight local timeThai Buddhist calendar BuddhistEra -543-01-01 midnight local time-----------------------------------------------------------------------</tt>