Class IndianCalendar
- java.lang.Object
-
- com.ibm.icu.util.Calendar
-
- com.ibm.icu.util.IndianCalendar
-
- All Implemented Interfaces:
Serializable,Cloneable,Comparable<Calendar>
public class IndianCalendar extends Calendar
IndianCalendaris a subclass ofGregorianCalendarthat numbers years since the birth of the Buddha. This is the civil calendar which is accepted by government of India as Indian National Calendar. The two calendars most widely used in India today are the Vikrama calendar followed in North India and the Shalivahana or Saka calendar which is followed in South India and Maharashtra. A variant of the Shalivahana Calendar was reformed and standardized as the Indian National calendar in 1957.Some details of Indian National Calendar (to be implemented) : The Months Month Length Start date (Gregorian) ================================================= 1 Chaitra 30/31 March 22* 2 Vaisakha 31 April 21 3 Jyaistha 31 May 22 4 Asadha 31 June 22 5 Sravana 31 July 23 6 Bhadra 31 August 23 7 Asvina 30 September 23 8 Kartika 30 October 23 9 Agrahayana 30 November 22 10 Pausa 30 December 22 11 Magha 30 January 21 12 Phalguna 30 February 20 In leap years, Chaitra has 31 days and starts on March 21 instead. The leap years of Gregorian calendar and Indian National Calendar are in synchornization. So When its a leap year in Gregorian calendar then Chaitra has 31 days. The Years Years are counted in the Saka Era, which starts its year 0 in 78AD (by gregorian calendar). So for eg. 9th June 2006 by Gregorian Calendar, is same as 19th of Jyaistha in 1928 of Saka era by Indian National Calendar.
The Indian Calendar has only one allowable era:
Saka Era. If the calendar is not in lenient mode (seesetLenient), dates before 1/1/1 Saka Era are rejected with anIllegalArgumentException.This class should not be subclassed.
IndianCalendar usually should be instantiated using
Calendar.getInstance(ULocale)passing in aULocalewith the tag"@calendar=Indian".- See Also:
Calendar,GregorianCalendar, Serialized Form- Status:
- Stable ICU 3.8.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.ibm.icu.util.Calendar
Calendar.FormatConfiguration, Calendar.WeekData
-
-
Field Summary
Fields Modifier and Type Field Description static intAGRAHAYANAConstant for Agrahayana, the 9th month of the Indian year.static intASADHAConstant for Asadha, the 4th month of the Indian year.static intASVINAConstant for Asvina, the 7th month of the Indian year.static intBHADRAConstant for Bhadra, the 6th month of the Indian year.static intCHAITRAConstant for Chaitra, the 1st month of the Indian year.static intIEConstant for the Indian Era.static intJYAISTHAConstant for Jyaistha, the 3rd month of the Indian year.static intKARTIKAConstant for Kartika, the 8th month of the Indian year.static intMAGHAConstant for Magha, the 11th month of the Indian year.static intPAUSAConstant for Pausa, the 10th month of the Indian year.static intPHALGUNAConstant for Phalguna, the 12th month of the Indian year.static intSRAVANAConstant for Sravana, the 5th month of the Indian year.static intVAISAKHAConstant for Vaisakha, the 2nd month of the Indian year.-
Fields inherited from class com.ibm.icu.util.Calendar
AM, AM_PM, APRIL, AUGUST, BASE_FIELD_COUNT, DATE, DAY_OF_MONTH, DAY_OF_WEEK, DAY_OF_WEEK_IN_MONTH, DAY_OF_YEAR, DECEMBER, DOW_LOCAL, DST_OFFSET, EPOCH_JULIAN_DAY, ERA, EXTENDED_YEAR, FEBRUARY, FRIDAY, GREATEST_MINIMUM, HOUR, HOUR_OF_DAY, INTERNALLY_SET, IS_LEAP_MONTH, JAN_1_1_JULIAN_DAY, JANUARY, JULIAN_DAY, JULY, JUNE, LEAST_MAXIMUM, MARCH, MAX_DATE, MAX_FIELD_COUNT, MAX_JULIAN, MAX_MILLIS, MAXIMUM, MAY, MILLISECOND, MILLISECONDS_IN_DAY, MIN_DATE, MIN_JULIAN, MIN_MILLIS, MINIMUM, MINIMUM_USER_STAMP, MINUTE, MONDAY, MONTH, NOVEMBER, OCTOBER, ONE_DAY, ONE_HOUR, ONE_MINUTE, ONE_SECOND, ONE_WEEK, ORDINAL_MONTH, PM, RESOLVE_REMAP, SATURDAY, SECOND, SEPTEMBER, SUNDAY, THURSDAY, TUESDAY, UNDECIMBER, UNSET, WALLTIME_FIRST, WALLTIME_LAST, WALLTIME_NEXT_VALID, WEDNESDAY, WEEK_OF_MONTH, WEEK_OF_YEAR, WEEKDAY, WEEKEND, WEEKEND_CEASE, WEEKEND_ONSET, YEAR, YEAR_WOY, ZONE_OFFSET
-
-
Constructor Summary
Constructors Constructor Description IndianCalendar()Constructs aIndianCalendarusing the current time in the default time zone with the defaultFORMATlocale.IndianCalendar(int year, int month, int date)Constructs aIndianCalendarwith the given date set in the default time zone with the defaultFORMATlocale.IndianCalendar(int year, int month, int date, int hour, int minute, int second)Constructs a IndianCalendar with the given date and time set for the default time zone with the defaultFORMATlocale.IndianCalendar(TimeZone zone)Constructs aIndianCalendarbased on the current time in the given time zone with the defaultFORMATlocale.IndianCalendar(TimeZone zone, ULocale locale)Constructs aIndianCalendarbased on the current time in the given time zone with the given locale.IndianCalendar(TimeZone zone, Locale aLocale)Constructs aIndianCalendarbased on the current time in the given time zone with the given locale.IndianCalendar(ULocale locale)Constructs aIndianCalendarbased on the current time in the default time zone with the given locale.IndianCalendar(Date date)Constructs aIndianCalendarwith the given date set in the default time zone with the defaultFORMATlocale.IndianCalendar(Locale aLocale)Constructs aIndianCalendarbased on the current time in the default time zone with the given locale.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected intgetRelatedYearDifference()Deprecated.This API is ICU internal only.StringgetType()[icu] Returns the calendar type name string for this Calendar object.protected voidhandleComputeFields(int julianDay)Subclasses may override this method to compute several fields specific to each calendar system.protected inthandleComputeMonthStart(int year, int month, boolean useMonth)Returns the Julian day number of day before the first day of the given month in the given extended year.protected inthandleGetExtendedYear()Returns the extended year defined by the current fields.protected inthandleGetLimit(int field, int limitType)Subclass API for defining limits of different types.protected inthandleGetMonthLength(int extendedYear, int month)Returns the number of days in the given month of the given extended year of this calendar system.protected inthandleGetYearLength(int extendedYear)Returns the number of days in the given extended year of this calendar system.-
Methods inherited from class com.ibm.icu.util.Calendar
add, after, before, clear, clear, clone, compareTo, complete, computeFields, computeGregorianFields, computeGregorianMonthStart, computeJulianDay, computeMillisInDay, computeMillisInDayLong, computeTime, computeZoneOffset, computeZoneOffset, equals, fieldDifference, fieldName, floorDivide, floorDivide, floorDivide, floorDivide, get, getActualMaximum, getActualMinimum, getAvailableLocales, getAvailableULocales, getDateAtTimePattern, getDateTimeFormat, getDateTimeFormat, getDateTimePattern, getDayOfWeekType, getDefaultDayInMonth, getDefaultMonthInYear, getDisplayName, getDisplayName, getFieldCount, getFieldResolutionTable, getFirstDayOfWeek, getGreatestMinimum, getGregorianDayOfMonth, getGregorianDayOfYear, getGregorianMonth, getGregorianYear, getInstance, getInstance, getInstance, getInstance, getInstance, getInstance, getKeywordValuesForLocale, getLeastMaximum, getLimit, getLocale, getMaximum, getMinimalDaysInFirstWeek, getMinimum, getRelatedYear, getRepeatedWallTimeOption, getSkippedWallTimeOption, getStamp, getTemporalMonthCode, getTime, getTimeInMillis, getTimeZone, getWeekData, getWeekDataForRegion, getWeekendTransition, gregorianMonthLength, gregorianPreviousMonthLength, handleComputeJulianDay, handleCreateFields, handleGetDateFormat, handleGetDateFormat, handleGetDateFormat, handleGetDateFormat, hashCode, haveDefaultCentury, inTemporalLeapYear, internalGet, internalGet, internalGetMonth, internalGetMonth, internalGetTimeInMillis, internalSet, isEquivalentTo, isEra0CountingBackward, isGregorianLeapYear, isLenient, isSet, isWeekend, isWeekend, julianDayToDayOfWeek, julianDayToMillis, millisToJulianDay, newerField, newestStamp, pinField, prepareGetActual, resolveFields, roll, roll, set, set, set, set, setFirstDayOfWeek, setLenient, setMinimalDaysInFirstWeek, setRelatedYear, setRepeatedWallTimeOption, setSkippedWallTimeOption, setTemporalMonthCode, setTime, setTimeInMillis, setTimeZone, setWeekData, toString, validateField, validateField, validateFields, weekNumber, weekNumber
-
-
-
-
Field Detail
-
CHAITRA
public static final int CHAITRA
Constant for Chaitra, the 1st month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
VAISAKHA
public static final int VAISAKHA
Constant for Vaisakha, the 2nd month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
JYAISTHA
public static final int JYAISTHA
Constant for Jyaistha, the 3rd month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
ASADHA
public static final int ASADHA
Constant for Asadha, the 4th month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
SRAVANA
public static final int SRAVANA
Constant for Sravana, the 5th month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
BHADRA
public static final int BHADRA
Constant for Bhadra, the 6th month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
ASVINA
public static final int ASVINA
Constant for Asvina, the 7th month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
KARTIKA
public static final int KARTIKA
Constant for Kartika, the 8th month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
AGRAHAYANA
public static final int AGRAHAYANA
Constant for Agrahayana, the 9th month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
PAUSA
public static final int PAUSA
Constant for Pausa, the 10th month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
MAGHA
public static final int MAGHA
Constant for Magha, the 11th month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
PHALGUNA
public static final int PHALGUNA
Constant for Phalguna, the 12th month of the Indian year.- See Also:
- Constant Field Values
- Status:
- Stable ICU 3.8.
-
IE
public static final int IE
Constant for the Indian Era. This is the only allowableERAvalue for the Indian calendar.- See Also:
Calendar.ERA, Constant Field Values- Status:
- Stable ICU 3.8.
-
-
Constructor Detail
-
IndianCalendar
public IndianCalendar()
Constructs aIndianCalendarusing the current time in the default time zone with the defaultFORMATlocale.- See Also:
ULocale.Category.FORMAT- Status:
- Stable ICU 3.8.
-
IndianCalendar
public IndianCalendar(TimeZone zone)
Constructs aIndianCalendarbased on the current time in the given time zone with the defaultFORMATlocale.- Parameters:
zone- the given time zone.- See Also:
ULocale.Category.FORMAT- Status:
- Stable ICU 3.8.
-
IndianCalendar
public IndianCalendar(Locale aLocale)
Constructs aIndianCalendarbased on the current time in the default time zone with the given locale.- Parameters:
aLocale- the given locale.- Status:
- Stable ICU 3.8.
-
IndianCalendar
public IndianCalendar(ULocale locale)
Constructs aIndianCalendarbased on the current time in the default time zone with the given locale.- Parameters:
locale- the given ulocale.- Status:
- Stable ICU 3.8.
-
IndianCalendar
public IndianCalendar(TimeZone zone, Locale aLocale)
Constructs aIndianCalendarbased on the current time in the given time zone with the given locale.- Parameters:
zone- the given time zone.aLocale- the given locale.- Status:
- Stable ICU 3.8.
-
IndianCalendar
public IndianCalendar(TimeZone zone, ULocale locale)
Constructs aIndianCalendarbased on the current time in the given time zone with the given locale.- Parameters:
zone- the given time zone.locale- the given ulocale.- Status:
- Stable ICU 3.8.
-
IndianCalendar
public IndianCalendar(Date date)
Constructs aIndianCalendarwith the given date set in the default time zone with the defaultFORMATlocale.- Parameters:
date- The date to which the new calendar is set.- See Also:
ULocale.Category.FORMAT- Status:
- Stable ICU 3.8.
-
IndianCalendar
public IndianCalendar(int year, int month, int date)Constructs aIndianCalendarwith the given date set in the default time zone with the defaultFORMATlocale.- Parameters:
year- The value used to set the calendar'sYEARtime field.month- The value used to set the calendar'sMONTHtime field. The value is 0-based. e.g., 0 for January.date- The value used to set the calendar'sDATEtime field.- See Also:
ULocale.Category.FORMAT- Status:
- Stable ICU 3.8.
-
IndianCalendar
public IndianCalendar(int year, int month, int date, int hour, int minute, int second)Constructs a IndianCalendar with the given date and time set for the default time zone with the defaultFORMATlocale.- Parameters:
year- The value used to set the calendar'sYEARtime field.month- The value used to set the calendar'sMONTHtime field. The value is 0-based. e.g., 0 for January.date- The value used to set the calendar'sDATEtime field.hour- The value used to set the calendar'sHOUR_OF_DAYtime field.minute- The value used to set the calendar'sMINUTEtime field.second- The value used to set the calendar'sSECONDtime field.- See Also:
ULocale.Category.FORMAT- Status:
- Stable ICU 3.8.
-
-
Method Detail
-
handleGetExtendedYear
protected int handleGetExtendedYear()
Returns the extended year defined by the current fields. This will use the EXTENDED_YEAR field or the YEAR and supra-year fields (such as ERA) specific to the calendar system, depending on which set of fields is newer.- Specified by:
handleGetExtendedYearin classCalendar- Returns:
- the extended year
- Status:
- Stable ICU 3.8.
-
handleGetYearLength
protected int handleGetYearLength(int extendedYear)
Returns the number of days in the given extended year of this calendar system. Subclasses should override this method if they can provide a more correct or more efficient implementation than the default implementation in Calendar.- Overrides:
handleGetYearLengthin classCalendar- Status:
- Stable ICU 3.8.
-
handleGetMonthLength
protected int handleGetMonthLength(int extendedYear, int month)Returns the number of days in the given month of the given extended year of this calendar system. Subclasses should override this method if they can provide a more correct or more efficient implementation than the default implementation in Calendar.- Overrides:
handleGetMonthLengthin classCalendar- Status:
- Stable ICU 3.8.
-
handleComputeFields
protected void handleComputeFields(int julianDay)
Subclasses may override this method to compute several fields specific to each calendar system. These are:- ERA
- YEAR
- MONTH
- DAY_OF_MONTH
- DAY_OF_YEAR
- EXTENDED_YEAR
In addition, subclasses should compute any subclass-specific fields, that is, fields from BASE_FIELD_COUNT to getFieldCount() - 1.
The default implementation in
Calendarimplements a pure proleptic Gregorian calendar.- Overrides:
handleComputeFieldsin classCalendar- Status:
- Stable ICU 3.8.
-
handleGetLimit
protected int handleGetLimit(int field, int limitType)Subclass API for defining limits of different types. Subclasses must implement this method to return limits for the following fields:ERA YEAR MONTH WEEK_OF_YEAR WEEK_OF_MONTH DAY_OF_MONTH DAY_OF_YEAR DAY_OF_WEEK_IN_MONTH YEAR_WOY EXTENDED_YEAR
- Specified by:
handleGetLimitin classCalendar- Parameters:
field- one of the above field numberslimitType- one ofMINIMUM,GREATEST_MINIMUM,LEAST_MAXIMUM, orMAXIMUM- Status:
- Stable ICU 3.8.
-
handleComputeMonthStart
protected int handleComputeMonthStart(int year, int month, boolean useMonth)Returns the Julian day number of day before the first day of the given month in the given extended year. Subclasses should override this method to implement their calendar system.- Specified by:
handleComputeMonthStartin classCalendar- Parameters:
year- the extended yearmonth- the zero-based month, or 0 if useMonth is falseuseMonth- if false, compute the day before the first day of the given year, otherwise, compute the day before the first day of the given month- Returns:
- the Julian day number of the day before the first day of the given month and year
- Status:
- Stable ICU 3.8.
-
getRelatedYearDifference
@Deprecated protected final int getRelatedYearDifference()
Deprecated.This API is ICU internal only.- Overrides:
getRelatedYearDifferencein classCalendar- Status:
- Internal. This API is ICU internal only.
-
getType
public String getType()
[icu] Returns the calendar type name string for this Calendar object. The returned string is the legacy ICU calendar attribute value, for example, "gregorian" or "japanese".See type="old type name" for the calendar attribute of locale IDs at http://www.unicode.org/reports/tr35/#Key_Type_Definitions
-
-