Class IndianCalendar

All Implemented Interfaces:
Serializable, Comparable<IndianCalendar>, CalendarDate, ChronoDisplay, Temporal<CalendarDate>, LocalizedPatternSupport

@CalendarType("indian") public final class IndianCalendar extends Calendrical<IndianCalendar.Unit,​IndianCalendar> implements LocalizedPatternSupport

Represents the national calendar of India.

Introduction

It is a reform calendar synchronized with the gregorian calendar and was introduced in year 1957 as an attempt to unify the various local calendars used in India. A special leap year rule was introduced as follows: First add to the year of Saka era the number 78, then determine if the sum is a gregorian leap year. See also Wikipedia. Note that the Indian national calendar is not widely used despite of its official status. Most Indian people prefer the gregorian calendar. The calendar day starts at midnight, like in gregorian calendar but in contrast to the old Hinduist tradition.

Following elements which are declared as constants are registered by this class

Furthermore, all elements defined in EpochDays and CommonElements are supported.

Example of usage

     ChronoFormatter<IndianCalendar> formatter =
       ChronoFormatter.ofPattern(
         "EEE, d. MMMM yyyy", PatternType.CLDR_DATE, Locale.ENGLISH, IndianCalendar.axis());
     PlainDate today = SystemClock.inLocalView().today();
     IndianCalendar indianDate = today.transform(IndianCalendar.class);
     System.out.println(formatter.format(indianDate));
 

Support for unicode ca-extensions

      Locale locale = Locale.forLanguageTag("en-u-ca-indian");
      ChronoFormatter<CalendarDate> f = ChronoFormatter.ofGenericCalendarStyle(DisplayMode.FULL, locale);
      assertThat(
          f.format(PlainDate.of(2017, 10, 1)),
          is("Sunday, Asvina 9, 1939 Saka"));
 
Since:
3.32/4.27
Author:
Meno Hochschild
See Also:
IndianEra, IndianMonth, NumberSystem.BENGALI, NumberSystem.DEVANAGARI, NumberSystem.GUJARATI, NumberSystem.TELUGU, Serialized Form
  • Field Details

  • Method Details

    • of

      public static IndianCalendar of(int iyear, IndianMonth imonth, int idom)

      Creates a new instance of an Indian calendar date.

      Parameters:
      iyear - Indian year in the range 1-999999921
      imonth - Indian month
      idom - Indian day of month in range 1-31
      Returns:
      new instance of IndianCalendar
      Throws:
      IllegalArgumentException - in case of any inconsistencies
    • of

      public static IndianCalendar of(int iyear, int imonth, int idom)

      Creates a new instance of an Indian calendar date.

      Parameters:
      iyear - Indian year in the range 1-999999921
      imonth - Indian month in range 1-12
      idom - Indian day of month in range 1-31
      Returns:
      new instance of IndianCalendar
      Throws:
      IllegalArgumentException - in case of any inconsistencies
    • nowInSystemTime

      public static IndianCalendar nowInSystemTime()

      Obtains the current calendar date in system time.

      Convenient short-cut for: SystemClock.inLocalView().now(IndianCalendar.axis()).

      Returns:
      current calendar date in system time zone using the system clock
      See Also:
      SystemClock.inLocalView(), ZonalClock.now(Chronology)
    • getEra

      public IndianEra getEra()

      Yields the Indian era.

      Returns:
      IndianEra.SAKA
    • getYear

      public int getYear()

      Yields the Indian year.

      Returns:
      int
    • getMonth

      public IndianMonth getMonth()

      Yields the Indian month.

      Returns:
      enum
    • getDayOfMonth

      public int getDayOfMonth()

      Yields the Indian day of month.

      Returns:
      int
    • getDayOfWeek

      public Weekday getDayOfWeek()

      Determines the day of week.

      The Indian calendar also uses a 7-day-week.

      Returns:
      Weekday
    • getDayOfYear

      public int getDayOfYear()

      Yields the Indian day of year.

      Returns:
      int
    • lengthOfMonth

      public int lengthOfMonth()

      Yields the length of current Indian month in days.

      Returns:
      int
    • lengthOfYear

      public int lengthOfYear()

      Yields the length of current Indian year in days.

      Returns:
      int
    • isLeapYear

      public boolean isLeapYear()

      Is the year of this date a leap year?

      Returns:
      boolean
    • isValid

      public static boolean isValid(int yearOfEra, int month, int dayOfMonth)

      Queries if given parameter values form a well defined calendar date.

      Parameters:
      yearOfEra - the year of era to be checked
      month - the month to be checked
      dayOfMonth - the day of month to be checked
      Returns:
      true if valid else false
      Since:
      3.34/4.29
      See Also:
      of(int, int, int)
    • at

      Creates a new local timestamp with this date and given wall time.

      If the time T24:00 is used then the resulting timestamp will automatically be normalized such that the timestamp will contain the following day instead.

      Parameters:
      time - wall time
      Returns:
      general timestamp as composition of this date and given time
    • atTime

      public GeneralTimestamp<IndianCalendar> atTime(int hour, int minute)

      Is equivalent to at(PlainTime.of(hour, minute)).

      Parameters:
      hour - hour of day in range (0-24)
      minute - minute of hour in range (0-59)
      Returns:
      general timestamp as composition of this date and given time
      Throws:
      IllegalArgumentException - if any argument is out of range
    • equals

      public boolean equals(Object obj)
      Description copied from class: Calendrical

      Based on the epoch day number and the calendar system.

      In other words: Two date object are equal if they have the same temporal position on the local timeline and have the same calendrical type. Subclasses which define further state attributes must override this method.

      If an only temporal comparison is required then the method Calendrical.isSimultaneous(CalendarDate) is to be used.

      Overrides:
      equals in class Calendrical<IndianCalendar.Unit,​IndianCalendar>
      See Also:
      Chronology.getChronoType()
    • hashCode

      public int hashCode()
      Description copied from class: Calendrical

      Based on the epoch day number.

      Overrides:
      hashCode in class Calendrical<IndianCalendar.Unit,​IndianCalendar>
    • toString

      public String toString()
      Description copied from class: TimePoint

      Provides a complete textual representation of the state of this time point.

      The textual description often follows the conventions of ISO-8601. Usually the description starts with the chronological informations which are coarse-grained and ends with those ones which are fine-grained (for example the ISO-notation YYYY-MM-DD).

      Specified by:
      toString in class TimePoint<IndianCalendar.Unit,​IndianCalendar>
    • getDefaultWeekmodel

      public static Weekmodel getDefaultWeekmodel()

      Obtains the standard week model of this calendar.

      The Indian calendar usually starts on Sunday.

      Returns:
      Weekmodel
    • axis

      public static TimeAxis<IndianCalendar.Unit,​IndianCalendar> axis()

      Returns the associated time axis.

      Returns:
      chronology