Class EraRules
java.lang.Object
com.ibm.icu.impl.EraRules
EraRules represents calendar era rules specified
in supplementalData/calendarData.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate static final intprivate static final intstatic final intprivate static final intprivate intprivate static final intprivate intprivate int[]private static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intcompareEncodedDateWithYMD(int encoded, int year, int month, int day) Compare an encoded date with another date specified by year/month/day.private static int[]decodeDate(int encodedDate, int[] fillIn) private static intencodeDate(int year, int month, int day) Encode year/month/date to a single integer.intGets the current era code.intgetEraCode(int year, int month, int day) Returns era code for the specified year/month/day.static EraRulesgetInstance(CalType calType, boolean includeTentativeEra) static EraRulesgetInstance(String calId, boolean includeTentativeEra) intGets maximum defined era code for the current calendarintGets number of effective erasint[]getStartDate(int eraCode, int[] fillIn) Gets start date of an eraintgetStartYear(int eraCode) Gets start year of an eraprivate voidprivate static booleanisSet(int startDate) private static booleanisValidRuleStartDate(int year, int month, int day)
-
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
-
getInstance
-
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 codefillIn- 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- Yearmonth- 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- yearmonth- 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 dateyear- Year of another datemonth- Month of another dateday- Day of another date- Returns:
- -1 when encoded date is earlier, 0 when two dates are same, and 1 when encoded date is later.
-