Class HinduMonth

java.lang.Object
net.time4j.calendar.hindu.HinduPrimitive
net.time4j.calendar.hindu.HinduMonth
All Implemented Interfaces:
Serializable, Comparable<HinduMonth>, Predicate<HinduCalendar>, ChronoCondition<HinduCalendar>

public final class HinduMonth extends HinduPrimitive implements Comparable<HinduMonth>, ChronoCondition<HinduCalendar>, Serializable

The Hindu month varies in length and might also have a leap state when used in lunisolar context.

Since:
5.6
Author:
Meno Hochschild
See Also:
Serialized Form
  • Field Details

    • RASI_NAMES

      public static final AttributeKey<Boolean> RASI_NAMES

      Format attribute which controls if Rasi names or traditional lunisolar names are used for Hindu months in the solar calendar.

      The default is defined by the Hindu variant in question. For example, Kerala prefers Rasi names while most other parts of India use the lunisolar forms.

      See Also:
      ChronoFormatter.with(AttributeKey, boolean)
  • Method Details

    • of

      public static HinduMonth of(IndianMonth month)

      Gets the Hindu month which corresponds to the given Indian month.

      Users have to invoke the method withLeap() in order to obtain a leap month in lunisolar context.

      Parameters:
      month - month of Indian national calendar
      Returns:
      associated Hindu month
    • ofLunisolar

      public static HinduMonth ofLunisolar(int month)

      Gets the Hindu month which corresponds to the given numerical value in lunisolar context.

      Users have to invoke the method withLeap() in order to obtain a leap month in lunisolar context. The first month is Chaitra.

      Parameters:
      month - month value in the range [1-12]
      Returns:
      Hindu month as wrapper around a number
      Throws:
      IllegalArgumentException - if given argument is out of range 1-12
    • ofSolar

      public static HinduMonth ofSolar(int month)

      Gets the Hindu month which corresponds to the given solar numerical value.

      Note: The first month of solar calendar is Mesa (or in lunisolar naming Vaishakha).

      Parameters:
      month - month value in the range [1-12]
      Returns:
      Hindu month as wrapper around a number
      Throws:
      IllegalArgumentException - if given argument is out of range 1-12
      See Also:
      getRasi(), getRasi(Locale)
    • getValue

      public IndianMonth getValue()

      Obtains the corresponding Indian month.

      Important note: Hindu months in lunisolar context might be expunged which simply means that there are gaps in the numbering of the months per year. And intercalated months have the same number.

      Returns:
      IndianMonth
    • getRasi

      public int getRasi()

      Obtains the value of solar month as the sun is going through the corresponding constellation (Rasi).

      The first solar month is VAISHAKHA.

      Returns:
      int
      See Also:
      ofSolar(int), getRasi(Locale)
    • getRasi

      public String getRasi(Locale locale)

      Obtains the localized text of solar month corresponding to the Hindu zodiac (Rasi).

      In many cases however, the lunisolar name is still used and can be obtained by getDisplayName(locale). If this month is in leap status then the localized word for "adhika" will be inserted before the name.

      Parameters:
      locale - localization parameter
      Returns:
      String
      See Also:
      getRasi(), getDisplayName(Locale)
    • getDisplayName

      public String getDisplayName(Locale locale)

      Equivalent to the expression getDisplayName(locale, TextWidth.WIDE, OutputContext.FORMAT).

      If this month is in leap status then the localized word for "adhika" will be inserted before the name.

      Parameters:
      locale - language setting
      Returns:
      descriptive text (long form, never null)
      See Also:
      getDisplayName(Locale, TextWidth, OutputContext)
    • getDisplayName

      public String getDisplayName(Locale locale, TextWidth width, OutputContext context)

      Gets the description text dependent on the locale and style parameters.

      The second argument controls the width of description while the third argument is only relevant for languages which make a difference between stand-alone forms and embedded text forms (does not matter in English).

      Note: Rasi names are not used by this method.

      If this month is in leap status then the localized word for "adhika" will be inserted before the name.

      Parameters:
      locale - language setting
      width - text width
      context - output context
      Returns:
      descriptive text for given locale and style (never null)
      See Also:
      getRasi(Locale)
    • isLeap

      public boolean isLeap()

      Determines if this month is in leap state (intercalated month).

      A leap month is followed by a normal month with same number.

      Specified by:
      isLeap in class HinduPrimitive
      Returns:
      boolean
    • withLeap

      public HinduMonth withLeap()

      Obtains the leap month version of this month.

      Leap months only exist in the lunisolar versions of the Hindu calendar.

      Returns:
      copy of this month but in leap state
    • 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
    • compareTo

      public int compareTo(HinduMonth other)

      Uses the comparing order of the lunisolar calendar.

      Leap months are sorted before months with same number.

      Specified by:
      compareTo in interface Comparable<HinduMonth>
      Parameters:
      other - another month to be compared with
      Returns:
      comparing result
    • test

      public boolean test(HinduCalendar context)
      Description copied from interface: ChronoCondition

      Decides if given context matches this condition.

      Due to better readability it is recommended to use following equivalent approach instead of this method::

        import static net.time4j.Weekday.SATURDAY;
        import static net.time4j.Month.JANUARY;
      
        PlainDate date = PlainDate.of(2014, JANUARY, 25);
        System.out.println(SATURDAY.test(date)); // direct use
        System.out.println(date.matches(SATURDAY)); // recommended callback
       
      Specified by:
      test in interface ChronoCondition<HinduCalendar>
      Specified by:
      test in interface Predicate<HinduCalendar>
      Parameters:
      context - context as base of testing this condition
      Returns:
      true if given time context matches this condition else false