@CalendarType(value="indian") public final class IndianCalendar extends Calendrical<IndianCalendar.Unit,IndianCalendar> implements LocalizedPatternSupport
Represents the national calendar of India.
It is a reform calendar synchronized with the gregorian calendar and was introduced in year 1957 as an attempt to unify the various local calendars used in India. A special leap year rule was introduced as follows: First add to the year of Saka era the number 78, then determine if the sum is a gregorian leap year. See also Wikipedia. Note that the Indian national calendar is not widely used despite of its official status. Most Indian people prefer the gregorian calendar. The calendar day starts at midnight, like in gregorian calendar but in contrast to the old Hinduist tradition.
Furthermore, all elements defined in EpochDays and CommonElements are supported.
ChronoFormatter<IndianCalendar> formatter =
ChronoFormatter.ofPattern(
"EEE, d. MMMM yyyy", PatternType.CLDR_DATE, Locale.ENGLISH, IndianCalendar.axis());
PlainDate today = SystemClock.inLocalView().today();
IndianCalendar indianDate = today.transform(IndianCalendar.class);
System.out.println(formatter.format(indianDate));
Locale locale = Locale.forLanguageTag("en-u-ca-indian");
ChronoFormatter<CalendarDate> f = ChronoFormatter.ofGenericCalendarStyle(DisplayMode.FULL, locale);
assertThat(
f.format(PlainDate.of(2017, 10, 1)),
is("Sunday, Asvina 9, 1939 Saka"));
IndianEra,
IndianMonth,
NumberSystem.BENGALI,
NumberSystem.DEVANAGARI,
NumberSystem.GUJARATI,
NumberSystem.TELUGU,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static class |
IndianCalendar.Unit
Defines some calendar units for the Indian calendar.
|
| Modifier and Type | Field and Description |
|---|---|
static StdCalendarElement<Integer,IndianCalendar> |
DAY_OF_MONTH
Represents the Indian day of month.
|
static StdCalendarElement<Weekday,IndianCalendar> |
DAY_OF_WEEK
Represents the Indian day of week.
|
static StdCalendarElement<Integer,IndianCalendar> |
DAY_OF_YEAR
Represents the Indian day of year.
|
static ChronoElement<IndianEra> |
ERA
Represents the Indian era.
|
static StdCalendarElement<IndianMonth,IndianCalendar> |
MONTH_OF_YEAR
Represents the Indian month.
|
static OrdinalWeekdayElement<IndianCalendar> |
WEEKDAY_IN_MONTH
Element with the ordinal day-of-week within given calendar month.
|
static StdCalendarElement<Integer,IndianCalendar> |
YEAR_OF_ERA
Represents the Indian year.
|
| Modifier and Type | Method and Description |
|---|---|
GeneralTimestamp<IndianCalendar> |
at(PlainTime time)
Creates a new local timestamp with this date and given wall time.
|
GeneralTimestamp<IndianCalendar> |
atTime(int hour,
int minute)
Is equivalent to
at(PlainTime.of(hour, minute)). |
static TimeAxis<IndianCalendar.Unit,IndianCalendar> |
axis()
Returns the associated time axis.
|
boolean |
equals(Object obj)
Based on the epoch day number and the calendar system.
|
int |
getDayOfMonth()
Yields the Indian day of month.
|
Weekday |
getDayOfWeek()
Determines the day of week.
|
int |
getDayOfYear()
Yields the Indian day of year.
|
static Weekmodel |
getDefaultWeekmodel()
Obtains the standard week model of this calendar.
|
IndianEra |
getEra()
Yields the Indian era.
|
IndianMonth |
getMonth()
Yields the Indian month.
|
int |
getYear()
Yields the Indian year.
|
int |
hashCode()
Based on the epoch day number.
|
boolean |
isLeapYear()
Is the year of this date a leap year?
|
static boolean |
isValid(int yearOfEra,
int month,
int dayOfMonth)
Queries if given parameter values form a well defined calendar date.
|
int |
lengthOfMonth()
Yields the length of current Indian month in days.
|
int |
lengthOfYear()
Yields the length of current Indian year in days.
|
static IndianCalendar |
nowInSystemTime()
Obtains the current calendar date in system time.
|
static IndianCalendar |
of(int iyear,
IndianMonth imonth,
int idom)
Creates a new instance of an Indian calendar date.
|
static IndianCalendar |
of(int iyear,
int imonth,
int idom)
Creates a new instance of an Indian calendar date.
|
String |
toString()
Provides a complete textual representation of the state of
this time point.
|
compareTo, getDaysSinceEpochUTC, isAfter, isBefore, isSimultaneous, minus, plusmax, min, minus, minus, plus, plus, until, untilcontains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withgetFormatPattern, getFormatPattern, useDynamicFormatPatternfrom, from, from, transform, transform, transform, transform, transform, transformisAfterAll, isAfterOrEqual, isBeforeAll, isBeforeOrEqual@FormattableElement(format="G") public static final ChronoElement<IndianEra> ERA
Represents the Indian era.
@FormattableElement(format="y") public static final StdCalendarElement<Integer,IndianCalendar> YEAR_OF_ERA
Represents the Indian year.
@FormattableElement(format="M", alt="L") public static final StdCalendarElement<IndianMonth,IndianCalendar> MONTH_OF_YEAR
Represents the Indian month.
@FormattableElement(format="d") public static final StdCalendarElement<Integer,IndianCalendar> DAY_OF_MONTH
Represents the Indian day of month.
@FormattableElement(format="D") public static final StdCalendarElement<Integer,IndianCalendar> DAY_OF_YEAR
Represents the Indian day of year.
@FormattableElement(format="E") public static final StdCalendarElement<Weekday,IndianCalendar> DAY_OF_WEEK
Represents the Indian day of week.
If the day-of-week is set to a new value then Time4J handles the Indian calendar week as starting on Sunday.
@FormattableElement(format="F") public static final OrdinalWeekdayElement<IndianCalendar> WEEKDAY_IN_MONTH
Element with the ordinal day-of-week within given calendar month.
public static IndianCalendar of(int iyear, IndianMonth imonth, int idom)
Creates a new instance of an Indian calendar date.
iyear - Indian year in the range 1-999999921imonth - Indian monthidom - Indian day of month in range 1-31IndianCalendarIllegalArgumentException - in case of any inconsistenciespublic static IndianCalendar of(int iyear, int imonth, int idom)
Creates a new instance of an Indian calendar date.
iyear - Indian year in the range 1-999999921imonth - Indian month in range 1-12idom - Indian day of month in range 1-31IndianCalendarIllegalArgumentException - in case of any inconsistenciespublic static IndianCalendar nowInSystemTime()
Obtains the current calendar date in system time.
Convenient short-cut for: SystemClock.inLocalView().now(IndianCalendar.axis()).
SystemClock.inLocalView(),
ZonalClock.now(Chronology)public IndianEra getEra()
Yields the Indian era.
IndianEra.SAKApublic int getYear()
Yields the Indian year.
public IndianMonth getMonth()
Yields the Indian month.
public int getDayOfMonth()
Yields the Indian day of month.
public Weekday getDayOfWeek()
Determines the day of week.
The Indian calendar also uses a 7-day-week.
public int getDayOfYear()
Yields the Indian day of year.
public int lengthOfMonth()
Yields the length of current Indian month in days.
public int lengthOfYear()
Yields the length of current Indian year in days.
public boolean isLeapYear()
Is the year of this date a leap year?
public static boolean isValid(int yearOfEra,
int month,
int dayOfMonth)
Queries if given parameter values form a well defined calendar date.
yearOfEra - the year of era to be checkedmonth - the month to be checkeddayOfMonth - the day of month to be checkedtrue if valid else falseof(int, int, int)public GeneralTimestamp<IndianCalendar> at(PlainTime time)
Creates a new local timestamp with this date and given wall time.
If the time T24:00 is used
then the resulting timestamp will automatically be normalized such
that the timestamp will contain the following day instead.
time - wall timepublic GeneralTimestamp<IndianCalendar> atTime(int hour, int minute)
Is equivalent to at(PlainTime.of(hour, minute)).
hour - hour of day in range (0-24)minute - minute of hour in range (0-59)IllegalArgumentException - if any argument is out of rangepublic boolean equals(Object obj)
CalendricalBased on the epoch day number and the calendar system.
In other words: Two date object are equal if they have the same temporal position on the local timeline and have the same calendrical type. Subclasses which define further state attributes must override this method.
If an only temporal comparison is required then the method
Calendrical.isSimultaneous(CalendarDate) is to be used.
equals in class Calendrical<IndianCalendar.Unit,IndianCalendar>Chronology.getChronoType()public int hashCode()
CalendricalBased on the epoch day number.
hashCode in class Calendrical<IndianCalendar.Unit,IndianCalendar>public String toString()
TimePointProvides a complete textual representation of the state of this time point.
The textual description often follows the conventions of ISO-8601. Usually the description starts with the chronological informations which are coarse-grained and ends with those ones which are fine-grained (for example the ISO-notation YYYY-MM-DD).
toString in class TimePoint<IndianCalendar.Unit,IndianCalendar>public static Weekmodel getDefaultWeekmodel()
Obtains the standard week model of this calendar.
The Indian calendar usually starts on Sunday.
public static TimeAxis<IndianCalendar.Unit,IndianCalendar> axis()
Returns the associated time axis.
Copyright © 2014–2021. All rights reserved.