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

public Class IndianCalendar

extends Calendar
Class Inheritance
Imports
java.util.Date, .Locale, com.ibm.icu.util.ULocale.Category

IndianCalendar is a subclass of GregorianCalendar that 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 (see setLenient), dates before 1/1/1 Saka Era are rejected with an IllegalArgumentException.

This class should not be subclassed.

IndianCalendar usually should be instantiated using com.ibm.icu.util.Calendar#getInstance(ULocale) passing in a ULocale with the tag "@calendar=Indian".

ICU Status
Stable since ICU 3.8.
See Also
com.ibm.icu.util.Calendar, com.ibm.icu.util.GregorianCalendar

Field Summary

Modifier and TypeField and Description
public static final int
AGRAHAYANA

Constant for Agrahayana, the 9th month of the Indian year.

public static final int
ASADHA

Constant for Asadha, the 4th month of the Indian year.

public static final int
ASVINA

Constant for Asvina, the 7th month of the Indian year.

public static final int
BHADRA

Constant for Bhadra, the 6th month of the Indian year.

public static final int
CHAITRA

Constant for Chaitra, the 1st month of the Indian year.

public static final int
IE

Constant for the Indian Era.

private static final int
private static final int
public static final int
JYAISTHA

Constant for Jyaistha, the 3rd month of the Indian year.

public static final int
KARTIKA

Constant for Kartika, the 8th month of the Indian year.

private static final int[][]
public static final int
MAGHA

Constant for Magha, the 11th month of the Indian year.

public static final int
PAUSA

Constant for Pausa, the 10th month of the Indian year.

public static final int
PHALGUNA

Constant for Phalguna, the 12th month of the Indian year.

private static final long
public static final int
SRAVANA

Constant for Sravana, the 5th month of the Indian year.

public static final int
VAISAKHA

Constant for Vaisakha, the 2nd month of the Indian year.

Inherited from com.ibm.icu.util.Calendar:
AMAM_PMAPRILAUGUSTBASE_FIELD_COUNTDATEDATE_PRECEDENCEDAY_OF_MONTHDAY_OF_WEEKDAY_OF_WEEK_IN_MONTHDAY_OF_YEARDECEMBERDOW_LOCALDOW_PRECEDENCEDST_OFFSETEPOCH_JULIAN_DAYERAEXTENDED_YEARFEBRUARYFRIDAYGREATEST_MINIMUMHOURHOUR_OF_DAYINTERNALLY_SETIS_LEAP_MONTHJAN_1_1_JULIAN_DAYJANUARYJULIAN_DAYJULYJUNELEAST_MAXIMUMMARCHMAX_DATEMAX_FIELD_COUNTMAX_JULIANMAX_MILLISMAXIMUMMAYMILLISECONDMILLISECONDS_IN_DAYMIN_DATEMIN_JULIANMIN_MILLISMINIMUMMINIMUM_USER_STAMPMINUTEMONDAYMONTHMONTH_PRECEDENCENOVEMBEROCTOBERONE_DAYONE_HOURONE_MINUTEONE_SECONDONE_WEEKORDINAL_MONTHPMRESOLVE_REMAPSATURDAYSECONDSEPTEMBERSUNDAYTHURSDAYTUESDAYUNDECIMBERUNSETWALLTIME_FIRSTWALLTIME_LASTWALLTIME_NEXT_VALIDWEDNESDAYWEEK_OF_MONTHWEEK_OF_YEARWEEKDAYWEEKENDWEEKEND_CEASEWEEKEND_ONSETYEARYEAR_WOYZONE_OFFSET

Constructor Summary

AccessConstructor and Description
public
IndianCalendar()

Constructs a IndianCalendar using the current time in the default time zone with the default FORMAT locale.

public
IndianCalendar(TimeZone
the given time zone.
zone
)

Constructs a IndianCalendar based on the current time in the given time zone with the default FORMAT locale.

public
IndianCalendar(Locale
the given locale.
aLocale
)

Constructs a IndianCalendar based on the current time in the default time zone with the given locale.

public
IndianCalendar(ULocale
the given ulocale.
locale
)

Constructs a IndianCalendar based on the current time in the default time zone with the given locale.

public
IndianCalendar(TimeZone
the given time zone.
zone
,
Locale
the given locale.
aLocale
)

Constructs a IndianCalendar based on the current time in the given time zone with the given locale.

public
IndianCalendar(TimeZone
the given time zone.
zone
,
ULocale
the given ulocale.
locale
)

Constructs a IndianCalendar based on the current time in the given time zone with the given locale.

public
IndianCalendar(Date
The date to which the new calendar is set.
date
)

Constructs a IndianCalendar with the given date set in the default time zone with the default FORMAT locale.

public
IndianCalendar(int
The value used to set the calendar's YEAR time field.
year
,
int
The value used to set the calendar's MONTH time field. The value is 0-based. e.g., 0 for January.
month
,
int
The value used to set the calendar's DATE time field.
date
)

Constructs a IndianCalendar with the given date set in the default time zone with the default FORMAT locale.

public
IndianCalendar(int
The value used to set the calendar's YEAR time field.
year
,
int
The value used to set the calendar's MONTH time field. The value is 0-based. e.g., 0 for January.
month
,
int
The value used to set the calendar's DATE time field.
date
,
int
The value used to set the calendar's HOUR_OF_DAY time field.
hour
,
int
The value used to set the calendar's MINUTE time field.
minute
,
int
The value used to set the calendar's SECOND time field.
second
)

Constructs a IndianCalendar with the given date and time set for the default time zone with the default FORMAT locale.

Method Summary

Modifier and TypeMethod and Description
public String
private double
gregorianToJD(int year, int month, int date)

protected void
handleComputeFields(int julianDay)

Overrides com.ibm.icu.util.Calendar.handleComputeFields.

Subclasses may override this method to compute several fields specific to each calendar system.
protected int
handleComputeMonthStart(int
the extended year
year
,
int
the zero-based month, or 0 if useMonth is false
month
,
boolean
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
useMonth
)

Implements abstract com.ibm.icu.util.Calendar.handleComputeMonthStart.

Returns the Julian day number of day before the first day of the given month in the given extended year.
protected int
handleGetExtendedYear()

Implements abstract com.ibm.icu.util.Calendar.handleGetExtendedYear.

Returns the extended year defined by the current fields.
protected int
handleGetLimit(int
one of the above field numbers
field
,
int
one of MINIMUM, GREATEST_MINIMUM, LEAST_MAXIMUM, or MAXIMUM
limitType
)

Implements abstract com.ibm.icu.util.Calendar.handleGetLimit.

Subclass API for defining limits of different types.
protected int
handleGetMonthLength(int extendedYear, int month)

Overrides com.ibm.icu.util.Calendar.handleGetMonthLength.

Returns the number of days in the given month of the given extended year of this calendar system.
protected int
handleGetYearLength(int extendedYear)

Overrides com.ibm.icu.util.Calendar.handleGetYearLength.

Returns the number of days in the given extended year of this calendar system.
private double
IndianToJD(int year, int month, int date)

Inherited from com.ibm.icu.util.Calendar:
addafterbeforeclearclearclonecompareTocompletecomputeFieldscomputeGregorianFieldscomputeGregorianMonthStartcomputeJulianDaycomputeMillisInDaycomputeMillisInDayLongcomputeTimecomputeZoneOffsetcomputeZoneOffsetequalsfieldDifferencefieldNamefloorDividefloorDividefloorDividefloorDividegetgetActualMaximumgetActualMinimumgetAvailableLocalesgetAvailableULocalesgetDateAtTimePatterngetDateTimeFormatgetDateTimeFormatgetDateTimePatterngetDayOfWeekTypegetDefaultDayInMonthgetDefaultMonthInYeargetDisplayNamegetDisplayNamegetFieldCountgetFieldResolutionTablegetFirstDayOfWeekgetGreatestMinimumgetGregorianDayOfMonthgetGregorianDayOfYeargetGregorianMonthgetGregorianYeargetInstancegetInstancegetInstancegetInstancegetInstancegetInstancegetKeywordValuesForLocalegetLeastMaximumgetLimitgetLocalegetMaximumgetMinimalDaysInFirstWeekgetMinimumgetRelatedYeargetRepeatedWallTimeOptiongetSkippedWallTimeOptiongetStampgetTemporalMonthCodegetTimegetTimeInMillisgetTimeZonegetWeekDatagetWeekDataForRegiongetWeekendTransitiongregorianMonthLengthgregorianPreviousMonthLengthhandleComputeJulianDayhandleCreateFieldshandleGetDateFormathandleGetDateFormathandleGetDateFormathandleGetDateFormathashCodehaveDefaultCenturyinTemporalLeapYearinternalGetinternalGetinternalGetMonthinternalGetMonthinternalGetTimeInMillisinternalSetisEquivalentToisGregorianLeapYearisLenientisSetisWeekendisWeekendjulianDayToDayOfWeekjulianDayToMillismillisToJulianDaynewerFieldnewestStamppinFieldprepareGetActualresolveFieldsrollrollsetsetsetsetsetFirstDayOfWeeksetLenientsetLocalesetMinimalDaysInFirstWeeksetRelatedYearsetRepeatedWallTimeOptionsetSkippedWallTimeOptionsetTemporalMonthCodesetTimesetTimeInMillissetTimeZonesetWeekDatatoStringvalidateFieldvalidateFieldvalidateFieldsweekNumberweekNumber

Field Detail

AGRAHAYANAback to summary
public static final int AGRAHAYANA

Constant for Agrahayana, the 9th month of the Indian year.

ICU Status
Stable since ICU 3.8.
ASADHAback to summary
public static final int ASADHA

Constant for Asadha, the 4th month of the Indian year.

ICU Status
Stable since ICU 3.8.
ASVINAback to summary
public static final int ASVINA

Constant for Asvina, the 7th month of the Indian year.

ICU Status
Stable since ICU 3.8.
BHADRAback to summary
public static final int BHADRA

Constant for Bhadra, the 6th month of the Indian year.

ICU Status
Stable since ICU 3.8.
CHAITRAback to summary
public static final int CHAITRA

Constant for Chaitra, the 1st month of the Indian year.

ICU Status
Stable since ICU 3.8.
IEback to summary
public static final int IE

Constant for the Indian Era. This is the only allowable ERA value for the Indian calendar.

ICU Status
Stable since ICU 3.8.
See Also
com.ibm.icu.util.Calendar#ERA
INDIAN_ERA_STARTback to summary
private static final int INDIAN_ERA_START
INDIAN_YEAR_STARTback to summary
private static final int INDIAN_YEAR_START
JYAISTHAback to summary
public static final int JYAISTHA

Constant for Jyaistha, the 3rd month of the Indian year.

ICU Status
Stable since ICU 3.8.
KARTIKAback to summary
public static final int KARTIKA

Constant for Kartika, the 8th month of the Indian year.

ICU Status
Stable since ICU 3.8.
LIMITSback to summary
private static final int[][] LIMITS

Hides com.ibm.icu.util.Calendar.LIMITS.

MAGHAback to summary
public static final int MAGHA

Constant for Magha, the 11th month of the Indian year.

ICU Status
Stable since ICU 3.8.
PAUSAback to summary
public static final int PAUSA

Constant for Pausa, the 10th month of the Indian year.

ICU Status
Stable since ICU 3.8.
PHALGUNAback to summary
public static final int PHALGUNA

Constant for Phalguna, the 12th month of the Indian year.

ICU Status
Stable since ICU 3.8.
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.ibm.icu.util.Calendar.serialVersionUID.

SRAVANAback to summary
public static final int SRAVANA

Constant for Sravana, the 5th month of the Indian year.

ICU Status
Stable since ICU 3.8.
VAISAKHAback to summary
public static final int VAISAKHA

Constant for Vaisakha, the 2nd month of the Indian year.

ICU Status
Stable since ICU 3.8.

Constructor Detail

IndianCalendarback to summary
public IndianCalendar()

Constructs a IndianCalendar using the current time in the default time zone with the default FORMAT locale.

ICU Status
Stable since ICU 3.8.
See Also
Category#FORMAT
IndianCalendarback to summary
public IndianCalendar(TimeZone zone)

Constructs a IndianCalendar based on the current time in the given time zone with the default FORMAT locale.

Parameters
zone:TimeZone

the given time zone.

ICU Status
Stable since ICU 3.8.
See Also
Category#FORMAT
IndianCalendarback to summary
public IndianCalendar(Locale aLocale)

Constructs a IndianCalendar based on the current time in the default time zone with the given locale.

Parameters
aLocale:Locale

the given locale.

ICU Status
Stable since ICU 3.8.
IndianCalendarback to summary
public IndianCalendar(ULocale locale)

Constructs a IndianCalendar based on the current time in the default time zone with the given locale.

Parameters
locale:ULocale

the given ulocale.

ICU Status
Stable since ICU 3.8.
IndianCalendarback to summary
public IndianCalendar(TimeZone zone, Locale aLocale)

Constructs a IndianCalendar based on the current time in the given time zone with the given locale.

Parameters
zone:TimeZone

the given time zone.

aLocale:Locale

the given locale.

ICU Status
Stable since ICU 3.8.
IndianCalendarback to summary
public IndianCalendar(TimeZone zone, ULocale locale)

Constructs a IndianCalendar based on the current time in the given time zone with the given locale.

Parameters
zone:TimeZone

the given time zone.

locale:ULocale

the given ulocale.

ICU Status
Stable since ICU 3.8.
IndianCalendarback to summary
public IndianCalendar(Date date)

Constructs a IndianCalendar with the given date set in the default time zone with the default FORMAT locale.

Parameters
date:Date

The date to which the new calendar is set.

ICU Status
Stable since ICU 3.8.
See Also
Category#FORMAT
IndianCalendarback to summary
public IndianCalendar(int year, int month, int date)

Constructs a IndianCalendar with the given date set in the default time zone with the default FORMAT locale.

Parameters
year:int

The value used to set the calendar's YEAR time field.

month:int

The value used to set the calendar's MONTH time field. The value is 0-based. e.g., 0 for January.

date:int

The value used to set the calendar's DATE time field.

ICU Status
Stable since ICU 3.8.
See Also
Category#FORMAT
IndianCalendarback to summary
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 default FORMAT locale.

Parameters
year:int

The value used to set the calendar's YEAR time field.

month:int

The value used to set the calendar's MONTH time field. The value is 0-based. e.g., 0 for January.

date:int

The value used to set the calendar's DATE time field.

hour:int

The value used to set the calendar's HOUR_OF_DAY time field.

minute:int

The value used to set the calendar's MINUTE time field.

second:int

The value used to set the calendar's SECOND time field.

ICU Status
Stable since ICU 3.8.
See Also
Category#FORMAT

Method Detail

getTypeback to summary
public String getType()

Overrides com.ibm.icu.util.Calendar.getType.

Doc from com.ibm.icu.util.Calendar.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

Returns:String

legacy calendar type name string

ICU Status
Stable since ICU 3.8.
gregorianToJDback to summary
private double gregorianToJD(int year, int month, int date)
handleComputeFieldsback to summary
protected void handleComputeFields(int julianDay)

Overrides com.ibm.icu.util.Calendar.handleComputeFields.

Doc from com.ibm.icu.util.Calendar.handleComputeFields.

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
Subclasses can refer to the DAY_OF_WEEK and DOW_LOCAL fields, which will be set when this method is called. Subclasses can also call the getGregorianXxx() methods to obtain Gregorian calendar equivalents for the given Julian day.

In addition, subclasses should compute any subclass-specific fields, that is, fields from BASE_FIELD_COUNT to getFieldCount() - 1.

The default implementation in Calendar implements a pure proleptic Gregorian calendar.

ICU Status
Stable since ICU 3.8.
handleComputeMonthStartback to summary
protected int handleComputeMonthStart(int year, int month, boolean useMonth)

Implements abstract com.ibm.icu.util.Calendar.handleComputeMonthStart.

Doc from com.ibm.icu.util.Calendar.handleComputeMonthStart.

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.

Parameters
year:int

the extended year

month:int

the zero-based month, or 0 if useMonth is false

useMonth:boolean

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:int

the Julian day number of the day before the first day of the given month and year

ICU Status
Stable since ICU 3.8.
handleGetExtendedYearback to summary
protected int handleGetExtendedYear()

Implements abstract com.ibm.icu.util.Calendar.handleGetExtendedYear.

Doc from com.ibm.icu.util.Calendar.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.

Returns:int

the extended year

ICU Status
Stable since ICU 3.8.
handleGetLimitback to summary
protected int handleGetLimit(int field, int limitType)

Implements abstract com.ibm.icu.util.Calendar.handleGetLimit.

Doc from com.ibm.icu.util.Calendar.handleGetLimit.

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
Parameters
field:int

one of the above field numbers

limitType:int

one of MINIMUM, GREATEST_MINIMUM, LEAST_MAXIMUM, or MAXIMUM

ICU Status
Stable since ICU 3.8.
handleGetMonthLengthback to summary
protected int handleGetMonthLength(int extendedYear, int month)

Overrides com.ibm.icu.util.Calendar.handleGetMonthLength.

Doc from com.ibm.icu.util.Calendar.handleGetMonthLength.

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.

ICU Status
Stable since ICU 3.8.
handleGetYearLengthback to summary
protected int handleGetYearLength(int extendedYear)

Overrides com.ibm.icu.util.Calendar.handleGetYearLength.

Doc from com.ibm.icu.util.Calendar.handleGetYearLength.

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.

ICU Status
Stable since ICU 3.8.
IndianToJDback to summary
private double IndianToJD(int year, int month, int date)