Class EraRules

java.lang.Object
com.ibm.icu.impl.EraRules

public class EraRules extends Object
EraRules represents calendar era rules specified in supplementalData/calendarData.
  • Field Details

    • MAX_ENCODED_START_YEAR

      private static final int MAX_ENCODED_START_YEAR
      See Also:
    • MIN_ENCODED_START_YEAR

      private static final int MIN_ENCODED_START_YEAR
      See Also:
    • MIN_ENCODED_START

      public static final int MIN_ENCODED_START
    • YEAR_MASK

      private static final int YEAR_MASK
      See Also:
    • MONTH_MASK

      private static final int MONTH_MASK
      See Also:
    • DAY_MASK

      private static final int DAY_MASK
      See Also:
    • startDates

      private int[] startDates
    • minEra

      private int minEra
    • numEras

      private int numEras
    • currentEra

      private int currentEra
  • Constructor Details

    • EraRules

      private EraRules(int[] startDates, int minEra, int numEras)
  • Method Details

    • getInstance

      public static EraRules getInstance(CalType calType, boolean includeTentativeEra)
    • getInstance

      public static EraRules getInstance(String calId, boolean includeTentativeEra)
    • getNumberOfEras

      public int getNumberOfEras()
      Gets number of effective eras
      Returns:
      number of effective eras (not the same as max era code)
    • getMaxEraCode

      public int getMaxEraCode()
      Gets maximum defined era code for the current calendar
      Returns:
      maximum defined era code
    • getStartDate

      public int[] getStartDate(int eraCode, int[] fillIn)
      Gets start date of an era
      Parameters:
      eraCode - Era code
      fillIn - Receives date fields if supplied. If null, or size of array is less than 3, then a new int[] will be newly allocated.
      Returns:
      An int array including values of year, month, day of month in this order. When an era has no start date, the result will be January 1st in year whose value is minimum integer.
    • getStartYear

      public int getStartYear(int eraCode)
      Gets start year of an era
      Parameters:
      eraCode - Era code
      Returns:
      The first year of an era. When a era has no start date, minimum integer value is returned.
    • getEraCode

      public int getEraCode(int year, int month, int day)
      Returns era code for the specified year/month/day.
      Parameters:
      year - Year
      month - Month (1-base)
      day - Day of month
      Returns:
      era code (or code of earliest era when date is before that era)
    • getCurrentEraCode

      public int getCurrentEraCode()
      Gets the current era code. This is calculated only once for an instance of EraRules. The current era calculation is based on the default time zone at the time of instantiation.
      Returns:
      era index of current era (or era code of earliest era when current date is before any era)
    • initCurrentEra

      private void initCurrentEra()
    • isSet

      private static boolean isSet(int startDate)
    • isValidRuleStartDate

      private static boolean isValidRuleStartDate(int year, int month, int day)
    • encodeDate

      private static int encodeDate(int year, int month, int day)
      Encode year/month/date to a single integer. year is high 16 bits (-32768 to 32767), month is next 8 bits and day of month is last 8 bits.
      Parameters:
      year - year
      month - month (1-base)
      day - day of month
      Returns:
      an encoded date.
    • decodeDate

      private static int[] decodeDate(int encodedDate, int[] fillIn)
    • compareEncodedDateWithYMD

      private static int compareEncodedDateWithYMD(int encoded, int year, int month, int day)
      Compare an encoded date with another date specified by year/month/day.
      Parameters:
      encoded - An encoded date
      year - Year of another date
      month - Month of another date
      day - Day of another date
      Returns:
      -1 when encoded date is earlier, 0 when two dates are same, and 1 when encoded date is later.