Class SexagesimalName

java.lang.Object
net.time4j.calendar.SexagesimalName
All Implemented Interfaces:
Serializable, Comparable<SexagesimalName>
Direct Known Subclasses:
CyclicYear

public class SexagesimalName extends Object implements Comparable<SexagesimalName>, Serializable

Represents the cyclic sexagesimal names used in East Asian calendars following a 60 unit cycle.

It is mainly used for cyclic years. The Chinese calendar also knows cyclic months and days.

Since:
5.7
Author:
Meno Hochschild
See Also:
Serialized Form
  • Method Details

    • of

      public static SexagesimalName of(int numberOfCycle)

      Obtains an instance of cyclic sexagesimal name.

      Parameters:
      numberOfCycle - cyclic number in the range 1-60
      Returns:
      SexagesimalName
      Throws:
      IllegalArgumentException - if the parameter is out of range
    • of

      public static SexagesimalName of(SexagesimalName.Stem stem, SexagesimalName.Branch branch)

      Obtains an instance of cyclic sexagesimal name.

      Parameters:
      stem - celestial stem
      branch - terrestrial branch
      Returns:
      SexagesimalName
      Throws:
      IllegalArgumentException - if the combination of stem and branch is invalid
    • getNumber

      public int getNumber()

      Obtains the associated cyclic number in the range 1-60.

      Returns:
      int
    • getStem

      public SexagesimalName.Stem getStem()

      Obtains the celestial stem of this cyclic sexagesimal name.

      Returns:
      Stem
    • getBranch

      public SexagesimalName.Branch getBranch()

      Obtains the terrestrial branch of this cyclic sexagesimal name.

      Returns:
      Branch
    • parse

      public static SexagesimalName parse(String text, Locale locale) throws ParseException

      Parses the given localized name as a combination of stem and branch to a cyclic sexagesimal name.

      The original Chinese names are usually not translatable. A few languages like Korean, Vietnamese and Russian use their own transcriptions. The pinyin-transcription (official Chinese romanization) serves as fallback for other languages. And the root locale will use a simplified version of pinyin without diacritic accents. This method will always expect a minus sign as separator between stem and branch unless the language is Chinese, Korean or Japanese.

      Parameters:
      text - the text to be parsed
      locale - language
      Returns:
      parsed cyclic sexagesimal name
      Throws:
      ParseException - if the text cannot be parsed
      See Also:
      getDisplayName(Locale)
    • getDisplayName

      public String getDisplayName(Locale locale)

      Obtains the localized name of this cyclic sexagesimal name.

      The original Chinese names are usually not translatable. A few languages like Korean, Vietnamese and Russian use their own transcriptions. The pinyin-transcription (official Chinese romanization) serves as fallback for other languages.

      Parameters:
      locale - language
      Returns:
      display name
      See Also:
      parse(String, Locale)
    • getZodiac

      public String getZodiac(Locale locale)

      Obtains the animal describing this cyclic sexagesimal name.

      Convenient short form for getBranch().getZodiac(locale).

      Parameters:
      locale - language
      Returns:
      name of associated zodiac animal
    • roll

      public SexagesimalName roll(int amount)

      Rolls this cyclic sexagesimal name by given amount.

      Parameters:
      amount - determines by how many units this instance should be rolled
      Returns:
      changed copy of this instance
    • compareTo

      public int compareTo(SexagesimalName other)
      Specified by:
      compareTo in interface Comparable<SexagesimalName>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object