Class Nengo
- All Implemented Interfaces:
Serializable
,CalendarEra
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"
- Since:
- 3.32/4.27
- Author:
- Meno Hochschild
- See Also:
- Serialized Form
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Represents a strategy how to select nengos. -
Field Summary
Modifier and TypeFieldDescriptionstatic Nengo
Heisei is valid from 1989-01-08 until 2019-04-30 (emperor Akihito).static Nengo
Meji is valid from year 1868 until 1912-07-29.static Nengo
The newest known nengo.static Nengo
Reiwa is valid from 2019-05-01 onwards (emperor Naruhito).static AttributeKey<Nengo.Selector>
Format attribute which helps to resolve possible ambivalences in parsing.static Nengo
Shōwa is valid from 1926-12-25 until 1989-01-07.static Nengo
Taishō is valid from 1912-07-30 until 1926-12-24. -
Method Summary
Modifier and TypeMethodDescriptionboolean
findNext()
Tries to find the next nengo in chronological order.Tries to find the previous nengo in chronological order.getDisplayName(Locale locale)
Equivalent togetDisplayName(locale, TextWidth.WIDE)
.getDisplayName(Locale locale, TextWidth width)
Obtains the localized name.int
Obtains the gregorian year which relates to the first day of associated Japanese year where this nengo was used the first time.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).list()
Obtains a list of all official nengos in chronological ascending order.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?name()
Obtains a descriptive text with romaji and the relevant year interval.static Nengo
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.parseRomaji(String romaji)
Tries to find suitable nengos for given representation in romaji.stream()
Obtains a stream of all official nengos in chronological ascending order.stream(Nengo.Selector selector)
Obtains a stream of all nengos in chronological ascending order selected by given selector.toString()
-
Field Details
-
MEIJI
Meji is valid from year 1868 until 1912-07-29.
It uses the lunisolar calendar until end of year 1872.
-
TAISHO
Taishō is valid from 1912-07-30 until 1926-12-24.
-
SHOWA
Shōwa is valid from 1926-12-25 until 1989-01-07.
-
HEISEI
Heisei is valid from 1989-01-08 until 2019-04-30 (emperor Akihito).
-
REIWA
Reiwa is valid from 2019-05-01 onwards (emperor Naruhito).
- Since:
- 5.3
-
NEWEST
The newest known nengo.
-
SELECTOR
Format attribute which helps to resolve possible ambivalences in parsing.Standard value is:
Nengo.Selector.OFFICIAL
-
-
Method Details
-
ofRelatedGregorianYear
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.
- Parameters:
year
- the gregorian year which relates to the first day of any Japanese year (New Year)- Returns:
- found nengo
- Throws:
IllegalArgumentException
- if no suitable nengo could be found for given year- See Also:
Nengo.Selector.OFFICIAL
,ofRelatedGregorianYear(int, Selector)
-
ofRelatedGregorianYear
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.
- Parameters:
year
- the gregorian year which relates to the first day of any Japanese year (New Year)selector
- strategy how to select nengos- Returns:
- found nengo
- Throws:
IllegalArgumentException
- if no suitable nengo could be found for given parameters
-
ofKanji
Tries to find a suitable nengo for given japanese kanji representation.
- Parameters:
kanji
- the representation in japanese kanji- Returns:
- suitable nengo with same kanji
- Throws:
IllegalArgumentException
- if no suitable nengo could be found for given kanji representation
-
parseRomaji
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".
- Parameters:
romaji
- the representation in romaji (hepburn variant)- Returns:
- unmodifiable list of suitable nengos maybe empty
-
stream
Obtains a stream of all official nengos in chronological ascending order.
- Returns:
- stream of nengos
- See Also:
Nengo.Selector.OFFICIAL
,stream(Selector)
-
stream
Obtains a stream of all nengos in chronological ascending order selected by given selector.
- Parameters:
selector
- strategy how to select nengos- Returns:
- stream of nengos
-
list
Obtains a list of all official nengos in chronological ascending order.
- Returns:
- unmodifiable list of nengos
- See Also:
Nengo.Selector.OFFICIAL
,list(Selector)
-
list
Obtains a list of all nengos in chronological ascending order selected by given selector.
- Parameters:
selector
- strategy how to select nengos- Returns:
- unmodifiable list of nengos
-
matches
Does this nengo match given selector?
- Parameters:
selector
- strategy how to select nengos- Returns:
true
if given selector would select this nengo elsefalse
-
getFirstRelatedGregorianYear
public int getFirstRelatedGregorianYear()Obtains the gregorian year which relates to the first day of associated Japanese year where this nengo was used the first time.
- Returns:
- related gregorian year
- See Also:
getStart()
-
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).
- Returns:
- gregorian date of first introduction of this nengo
- See Also:
getFirstRelatedGregorianYear()
-
isModern
public boolean isModern()Determines if this nengo is used by modern Japan (since Meiji).
- Returns:
- boolean
-
getDisplayName
Equivalent to
getDisplayName(locale, TextWidth.WIDE)
.- Parameters:
locale
- the language which determines the name to be displayed- Returns:
- localized display name
- See Also:
getDisplayName(Locale, TextWidth)
-
getDisplayName
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.
- Parameters:
locale
- the language which determines the name to be displayedwidth
- text width (not relevant for older nengos)- Returns:
- localized display name
-
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).
- Returns:
- next nengo which is only present if this nengo is not the newest 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).
- Returns:
- previous nengo which is only present if this nengo is not the first nengo
-
name
Obtains a descriptive text with romaji and the relevant year interval.
- Specified by:
name
in interfaceCalendarEra
- Returns:
- String
-
equals
-
hashCode
public int hashCode() -
toString
-