Top Description Fields Constructors Methods
com.ibm.icu.impl

public Class EraRules

extends Object
Class Inheritance
Imports
java.util.Arrays, com.ibm.icu.util.ICUException, .TimeZone, .UResourceBundle, .UResourceBundleIterator

EraRules represents calendar era rules specified in supplementalData/calendarData.
Author
Yoshito Umaoka

Field Summary

Modifier and TypeField and Description
private int
private static final int
private static final int
public static final int
private static final int
private static final int
private int
private int[]
private static final int

Constructor Summary

AccessConstructor and Description
private
EraRules(int[] startDates, int numEras)

Method Summary

Modifier and TypeMethod and Description
private static int

Returns:

-1 when encoded date is earlier, 0 when two dates are same, and 1 when encoded date is later.
compareEncodedDateWithYMD
(int
An encoded date
encoded
,
int
Year of another date
year
,
int
Month of another date
month
,
int
Day of another date
day
)

Compare an encoded date with another date specified by year/month/day.

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

private static int

Returns:

an encoded date.
encodeDate
(int
year
year
,
int
month (1-base)
month
,
int
day of month
day
)

Encode year/month/date to a single integer.

public int

Returns:

era index of current era (or 0, when current date is before the first era)
getCurrentEraIndex
()

Gets the current era index.

public int

Returns:

era index (or 0, when the specified date is before the first era)
getEraIndex
(int
Year
year
,
int
Month (1-base)
month
,
int
Day of month
day
)

Returns era index for the specified year/month/day.

public static EraRules
getInstance(CalType calType, boolean includeTentativeEra)

public int

Returns:

number of effective eras
getNumberOfEras
()

Gets number of effective eras

public int[]

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.
getStartDate
(int
Era index
eraIdx
,
int[]
Receives date fields if supplied. If null, or size of array is less than 3, then a new int[] will be newly allocated.
fillIn
)

Gets start date of an era

public int

Returns:

The first year of an era. When a era has no start date, minimum integer value is returned.
getStartYear
(int
Era index
eraIdx
)

Gets start year of an era

private void
private static boolean
isSet(int startDate)

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentEraback to summary
private int currentEra
DAY_MASKback to summary
private static final int DAY_MASK
MAX_ENCODED_START_YEARback to summary
private static final int MAX_ENCODED_START_YEAR
MIN_ENCODED_STARTback to summary
public static final int MIN_ENCODED_START
MIN_ENCODED_START_YEARback to summary
private static final int MIN_ENCODED_START_YEAR
MONTH_MASKback to summary
private static final int MONTH_MASK
numErasback to summary
private int numEras
startDatesback to summary
private int[] startDates
YEAR_MASKback to summary
private static final int YEAR_MASK

Constructor Detail

EraRulesback to summary
private EraRules(int[] startDates, int numEras)

Method Detail

compareEncodedDateWithYMDback to summary
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:int

An encoded date

year:int

Year of another date

month:int

Month of another date

day:int

Day of another date

Returns:int

-1 when encoded date is earlier, 0 when two dates are same, and 1 when encoded date is later.

decodeDateback to summary
private static int[] decodeDate(int encodedDate, int[] fillIn)
encodeDateback to summary
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:int

year

month:int

month (1-base)

day:int

day of month

Returns:int

an encoded date.

getCurrentEraIndexback to summary
public int getCurrentEraIndex()

Gets the current era index. 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:int

era index of current era (or 0, when current date is before the first era)

getEraIndexback to summary
public int getEraIndex(int year, int month, int day)

Returns era index for the specified year/month/day.

Parameters
year:int

Year

month:int

Month (1-base)

day:int

Day of month

Returns:int

era index (or 0, when the specified date is before the first era)

getInstanceback to summary
public static EraRules getInstance(CalType calType, boolean includeTentativeEra)
getNumberOfErasback to summary
public int getNumberOfEras()

Gets number of effective eras

Returns:int

number of effective eras

getStartDateback to summary
public int[] getStartDate(int eraIdx, int[] fillIn)

Gets start date of an era

Parameters
eraIdx:int

Era index

fillIn:int[]

Receives date fields if supplied. If null, or size of array is less than 3, then a new int[] will be newly allocated.

Returns:int[]

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.

getStartYearback to summary
public int getStartYear(int eraIdx)

Gets start year of an era

Parameters
eraIdx:int

Era index

Returns:int

The first year of an era. When a era has no start date, minimum integer value is returned.

initCurrentEraback to summary
private void initCurrentEra()
isSetback to summary
private static boolean isSet(int startDate)
isValidRuleStartDateback to summary
private static boolean isValidRuleStartDate(int year, int month, int day)