public final class Nengo extends Object implements CalendarEra, Serializable
It is possible to register a new nengo by setting the system property "net.time4j.calendar.japanese.supplemental.era". Its value is a sequence of key-value-pairs (without any space or tab). The keys "name" (given in romaji), "kanji" (japanese - 2 chars) and "since" (ISO-8601-date) are mandatory. If necessary, the optional keys "chinese" (2 chars), "korean" or "russian" can be specified, too. Example:
"-Dnet.time4j.calendar.japanese.supplemental.era name=newEra,kanji=KK,since=9999-12-31"
| Modifier and Type | Class and Description |
|---|---|
static class |
Nengo.Selector
Represents a strategy how to select nengos.
|
| Modifier and Type | Field and Description |
|---|---|
static Nengo |
HEISEI
Heisei is valid from 1989-01-08 until 2019-04-30 (emperor Akihito).
|
static Nengo |
MEIJI
Meji is valid from year 1868 until 1912-07-29.
|
static Nengo |
NEWEST
The newest known nengo.
|
static Nengo |
REIWA
Reiwa is valid from 2019-05-01 onwards (emperor Naruhito).
|
static AttributeKey<Nengo.Selector> |
SELECTOR
Format attribute which helps to resolve possible ambivalences in parsing.
|
static Nengo |
SHOWA
Shōwa is valid from 1926-12-25 until 1989-01-07.
|
static Nengo |
TAISHO
Taishō is valid from 1912-07-30 until 1926-12-24.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
Optional<Nengo> |
findNext()
Tries to find the next nengo in chronological order.
|
Optional<Nengo> |
findPrevious()
Tries to find the previous nengo in chronological order.
|
String |
getDisplayName(Locale locale)
Equivalent to
getDisplayName(locale, TextWidth.WIDE). |
String |
getDisplayName(Locale locale,
TextWidth width)
Obtains the localized name.
|
int |
getFirstRelatedGregorianYear()
Obtains the gregorian year which relates to the first day of associated Japanese year
where this nengo was used the first time.
|
PlainDate |
getStart()
Obtains the first date when this nengo took effect.
|
int |
hashCode() |
boolean |
isModern()
Determines if this nengo is used by modern Japan (since Meiji).
|
static List<Nengo> |
list()
Obtains a list of all official nengos in chronological ascending order.
|
static List<Nengo> |
list(Nengo.Selector selector)
Obtains a list of all nengos in chronological ascending order selected by given selector.
|
boolean |
matches(Nengo.Selector selector)
Does this nengo match given selector?
|
String |
name()
Obtains a descriptive text with romaji and the relevant year interval.
|
static Nengo |
ofKanji(String kanji)
Tries to find a suitable nengo for given japanese kanji representation.
|
static Nengo |
ofRelatedGregorianYear(int year)
Obtains the official nengo for given related gregorian year.
|
static Nengo |
ofRelatedGregorianYear(int year,
Nengo.Selector selector)
Obtains the nengo for given related gregorian year and selector strategy.
|
static List<Nengo> |
parseRomaji(String romaji)
Tries to find suitable nengos for given representation in romaji.
|
static Stream<Nengo> |
stream()
Obtains a stream of all official nengos in chronological ascending order.
|
static Stream<Nengo> |
stream(Nengo.Selector selector)
Obtains a stream of all nengos in chronological ascending order selected by given selector.
|
String |
toString() |
public static final Nengo MEIJI
Meji is valid from year 1868 until 1912-07-29.
It uses the lunisolar calendar until end of year 1872.
public static final Nengo TAISHO
Taishō is valid from 1912-07-30 until 1926-12-24.
public static final Nengo SHOWA
Shōwa is valid from 1926-12-25 until 1989-01-07.
public static final Nengo HEISEI
Heisei is valid from 1989-01-08 until 2019-04-30 (emperor Akihito).
public static final Nengo REIWA
Reiwa is valid from 2019-05-01 onwards (emperor Naruhito).
public static final Nengo NEWEST
The newest known nengo.
public static final AttributeKey<Nengo.Selector> SELECTOR
Standard value is: Nengo.Selector.OFFICIAL
public static Nengo ofRelatedGregorianYear(int year)
Obtains the official nengo for given related gregorian year.
In case two or more nengos happen for one given year, Time4J will choose the latest nengo whose first related gregorian year is still smaller than or equal to given year.
year - the gregorian year which relates to the first day of any Japanese year (New Year)IllegalArgumentException - if no suitable nengo could be found for given yearNengo.Selector.OFFICIAL,
ofRelatedGregorianYear(int, Selector)public static Nengo ofRelatedGregorianYear(int year, Nengo.Selector selector)
Obtains the nengo for given related gregorian year and selector strategy.
In case two or more nengos happen for one given year, Time4J will choose the latest nengo whose first related gregorian year is still smaller than or equal to given year.
year - the gregorian year which relates to the first day of any Japanese year (New Year)selector - strategy how to select nengosIllegalArgumentException - if no suitable nengo could be found for given parameterspublic static Nengo ofKanji(String kanji)
Tries to find a suitable nengo for given japanese kanji representation.
kanji - the representation in japanese kanjiIllegalArgumentException - if no suitable nengo could be found for given kanji representationpublic static List<Nengo> parseRomaji(String romaji)
Tries to find suitable nengos for given representation in romaji.
The internal parser is case-insensitive and able to translate vowels with circumflex into vowels with macron. Some labels are ambivalent. One single nengo can even have more than one romaji representation. For example, the label "Shōwa" has existed three times in history (for different nengos). Here the first nengo "Jōwa" (year 834) was also read as "Shōwa".
romaji - the representation in romaji (hepburn variant)public static Stream<Nengo> stream()
Obtains a stream of all official nengos in chronological ascending order.
Nengo.Selector.OFFICIAL,
stream(Selector)public static Stream<Nengo> stream(Nengo.Selector selector)
Obtains a stream of all nengos in chronological ascending order selected by given selector.
selector - strategy how to select nengospublic static List<Nengo> list()
Obtains a list of all official nengos in chronological ascending order.
Nengo.Selector.OFFICIAL,
list(Selector)public static List<Nengo> list(Nengo.Selector selector)
Obtains a list of all nengos in chronological ascending order selected by given selector.
selector - strategy how to select nengospublic boolean matches(Nengo.Selector selector)
Does this nengo match given selector?
selector - strategy how to select nengostrue if given selector would select this nengo else falsepublic int getFirstRelatedGregorianYear()
Obtains the gregorian year which relates to the first day of associated Japanese year where this nengo was used the first time.
getStart()public PlainDate getStart()
Obtains the first date when this nengo took effect.
Due to the differences between old Japanese calendar and modern gregorian variant, it is possible that the year of start date deviates from the related gregorian year. An example is the nengo Eichō with the related gregorian year 1096 although it started first on AD-1096-01-03 (julian).
getFirstRelatedGregorianYear()public boolean isModern()
Determines if this nengo is used by modern Japan (since Meiji).
public String getDisplayName(Locale locale)
Equivalent to getDisplayName(locale, TextWidth.WIDE).
locale - the language which determines the name to be displayedgetDisplayName(Locale, TextWidth)public String getDisplayName(Locale locale, TextWidth width)
Obtains the localized name.
For all modern nengos (Meiji or later), the display name will be determined on base of best efforts, possibly in narrow or abbreviated notation, too. However, older nengos are localized in a simplified manner: There is no support for abbreviated or narrow text forms, and the localization is limited to the languages Japanese, Chinese, Korean and Russian (based on Wikipedia). All other languages will be printed using the hebonshiki romaji system.
locale - the language which determines the name to be displayedwidth - text width (not relevant for older nengos)public Optional<Nengo> findNext()
Tries to find the next nengo in chronological order.
Note: If this nengo represents a nengo of northern court in the Nanboku-chō period (1336-1392) then the next nengo will be the next one of northern court only but not of southern court. If this nengo is the last one of northern court then the next nengo will be Ōei (1394).
public Optional<Nengo> findPrevious()
Tries to find the previous nengo in chronological order.
Note: If this nengo represents a nengo of northern court in the Nanboku-chō period (1336-1392) then the previous nengo will be the previous one of northern court only but not of southern court. If this nengo is the first one of northern court then the previous nengo will be Genkō: (1391).
public String name()
Obtains a descriptive text with romaji and the relevant year interval.
name in interface CalendarEraCopyright © 2014–2021. All rights reserved.