Class EthiopianCalendar
- All Implemented Interfaces:
Serializable,Comparable<EthiopianCalendar>,CalendarDate,ChronoDisplay,Temporal<CalendarDate>,LocalizedPatternSupport
Represents the calendar used in Ethiopia.
Introduction
It is built on the base of the Coptic calendar but uses two different eras. Another difference to Coptic calendar is the day starting in the morning at 06:00 (usual approximation for sunrise). For more details see Intro to the Ethiopic Calendar.
Following elements which are declared as constants are registered by this class
DAY_OF_WEEKDAY_OF_MONTHDAY_OF_YEARWEEKDAY_IN_MONTHMONTH_OF_YEARYEAR_OF_ERAERAEVANGELISTTABOT
Furthermore, all elements defined in EpochDays and CommonElements are supported.
Example of usage
// printing to English
ChronoFormatter<EthiopianCalendar> formatter =
ChronoFormatter.setUp(EthiopianCalendar.axis(), Locale.ENGLISH)
.addPattern("EEE, d. MMMM yyyy", PatternType.CLDR_DATE).build();
PlainDate today = SystemClock.inLocalView().today();
EthiopianCalendar ethiopianDate = today.transform(EthiopianCalendar.class); // conversion at noon
System.out.println(formatter.format(ethiopianDate));
// parsing text in Amharic (requires Ethiopic unicode font for proper view in browser)
ChronoFormatter<EthiopianCalendar> formatter =
ChronoFormatter.setUp(EthiopianCalendar.class, new Locale("am"))
.addPattern("MMMM d ", PatternType.CLDR_DATE)
.startSection(Attributes.NUMBER_SYSTEM, NumberSystem.ETHIOPIC)
.addInteger(EthiopianCalendar.YEAR_OF_ERA, 1, 9)
.endSection()
.addLiteral(" (")
.addText(EthiopianCalendar.EVANGELIST)
.addPattern(") G", PatternType.CLDR_DATE)
.build();
String input = "ጥቅምት 11 ፲፱፻፺፯ (ማቴዎስ) ዓ/ም";
EthiopianCalendar ethio = formatter.parse(input);
System.out.println(ethio); // AMETE_MIHRET-1997-02-11
Support for unicode ca-extensions
ZonalOffset offset = ZonalOffset.ofHours(OffsetSign.AHEAD_OF_UTC, 3);
ChronoFormatter<Moment> f =
ChronoFormatter.ofGenericMomentPattern("G, yyyy-MM-dd hh:mm a XXX", Locale.ENGLISH)
.withTimezone(offset)
.with(Locale.forLanguageTag("en-US-u-ca-ethiopic"));
assertThat(
f.parse("Amete Mihret, 2008-03-09 09:45 pm +03:00"),
is(PlainTimestamp.of(2015, 11, 19, 21, 45).at(offset)));
- Since:
- 3.11/4.8
- Author:
- Meno Hochschild
- See Also:
EthiopianEra,EthiopianMonth,EthiopianTime,NumberSystem.ETHIOPIC, Serialized Form
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefines some calendar units for the Ethiopian calendar. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic StdCalendarElement<Integer,EthiopianCalendar>Represents the Ethiopian day of month.static StdCalendarElement<Weekday,EthiopianCalendar>Represents the Ethiopian day of week.static StdCalendarElement<Integer,EthiopianCalendar>Represents the Ethiopian day of year.static ChronoElement<EthiopianEra>Represents the Ethiopian era.static ChronoElement<Evangelist>Represents the evangelist associated with a year of the Ethiopian leap year cycle.Represents the Ethiopian month.static TextElement<Tabot>Represents the tabot name of the associated day-of-month.Element with the ordinal day-of-week within given calendar month.static StdCalendarElement<Integer,EthiopianCalendar>Represents the Ethiopian year. -
Method Summary
Modifier and TypeMethodDescriptionat(EthiopianTime time)Creates a new local timestamp with this date and given Ethiopian time.axis()Returns the associated time axis.booleanBased on the epoch day number and the calendar system.intYields the Ethiopian day of month.Determines the day of week.intYields the Ethiopian day of year.static WeekmodelObtains the standard week model of this calendar.getEra()Yields the Ethiopian era.getMonth()Yields the Ethiopian month.intgetYear()Yields the Ethiopian year.inthashCode()Based on the epoch day number.booleanIs the year of this date a leap year?static booleanisValid(EthiopianEra era, int yearOfEra, int month, int dayOfMonth)Queries if given parameter values form a well defined calendar date.intYields the length of current Ethiopian month in days.intYields the length of current Ethiopian year in days.static EthiopianCalendarObtains the current calendar date in system time.static EthiopianCalendarof(EthiopianEra era, int yearOfEra, int month, int dayOfMonth)Creates a new instance of an Ethiopian calendar date.static EthiopianCalendarof(EthiopianEra era, int yearOfEra, EthiopianMonth month, int dayOfMonth)Creates a new instance of an Ethiopian calendar date.toString()Provides a complete textual representation of the state of this time point.Methods inherited from class net.time4j.engine.Calendrical
compareTo, getDaysSinceEpochUTC, isAfter, isBefore, isSimultaneous, minus, plusMethods inherited from class net.time4j.engine.TimePoint
max, min, minus, minus, plus, plus, until, untilMethods inherited from class net.time4j.engine.ChronoEntity
contains, get, get, getInt, getMaximum, getMinimum, getRegisteredElements, getTimezone, hasTimezone, isValid, isValid, isValid, matches, with, with, with, withMethods inherited from interface net.time4j.engine.CalendarDate
transform, transform, transform, transform, transform, transformMethods inherited from interface net.time4j.format.LocalizedPatternSupport
getFormatPattern, getFormatPattern, useDynamicFormatPatternMethods inherited from interface net.time4j.engine.Temporal
isAfterAll, isAfterOrEqual, isBeforeAll, isBeforeOrEqual
-
Field Details
-
ERA
Represents the Ethiopian era.
A change of the era has no effect.
-
YEAR_OF_ERA
@FormattableElement(format="y") public static final StdCalendarElement<Integer,EthiopianCalendar> YEAR_OF_ERARepresents the Ethiopian year.
Note: The format engine of Time4J uses the Ethiopic numeral system for calendar years by default if the language is Amharic.
- See Also:
NumberSystem.ETHIOPIC
-
MONTH_OF_YEAR
@FormattableElement(format="M", alt="L") public static final StdCalendarElement<EthiopianMonth,EthiopianCalendar> MONTH_OF_YEARRepresents the Ethiopian month.
-
DAY_OF_MONTH
@FormattableElement(format="d") public static final StdCalendarElement<Integer,EthiopianCalendar> DAY_OF_MONTHRepresents the Ethiopian day of month.
-
DAY_OF_YEAR
@FormattableElement(format="D") public static final StdCalendarElement<Integer,EthiopianCalendar> DAY_OF_YEARRepresents the Ethiopian day of year.
-
DAY_OF_WEEK
@FormattableElement(format="E") public static final StdCalendarElement<Weekday,EthiopianCalendar> DAY_OF_WEEKRepresents the Ethiopian day of week.
If the day-of-week is set to a new value then Time4J handles the Ethiopian calendar week as starting on Sunday (deviation from Coptic calendar).
-
WEEKDAY_IN_MONTH
@FormattableElement(format="F") public static final OrdinalWeekdayElement<EthiopianCalendar> WEEKDAY_IN_MONTHElement with the ordinal day-of-week within given calendar month.
-
EVANGELIST
Represents the evangelist associated with a year of the Ethiopian leap year cycle.
The fourth evangelist (John) is always associated with a leap year.
-
TABOT
Represents the tabot name of the associated day-of-month.
Example of usage in formatting:
ChronoFormatter<EthiopianCalendar> f = ChronoFormatter.setUp(EthiopianCalendar.axis(), new Locale("am")) .addPattern("d MMMM y G", PatternType.CLDR_DATE) .addLiteral(" (") .addText(EthiopianCalendar.TABOT) .addLiteral(')') .build(); String s = f.format(EthiopianCalendar.of(EthiopianEra.AMETE_MIHRET, 2007, 6, 25));
-
-
Method Details
-
of
public static EthiopianCalendar of(EthiopianEra era, int yearOfEra, EthiopianMonth month, int dayOfMonth)Creates a new instance of an Ethiopian calendar date.
- Parameters:
era- Ethiopian erayearOfEra- Ethiopian year of era in the range 1-9999 (1-15499 if amete alem)month- Ethiopian monthdayOfMonth- Ethiopian day of month in the range 1-30- Returns:
- new instance of
EthiopianCalendar - Throws:
IllegalArgumentException- in case of any inconsistencies- Since:
- 3.11/4.8
-
of
Creates a new instance of an Ethiopian calendar date.
- Parameters:
era- Ethiopian erayearOfEra- Ethiopian year of era in the range 1-9999 (1-15499 if amete alem)month- Ethiopian month in the range 1-13dayOfMonth- Ethiopian day of month in the range 1-30- Returns:
- new instance of
EthiopianCalendar - Throws:
IllegalArgumentException- in case of any inconsistencies- Since:
- 3.11/4.8
-
nowInSystemTime
Obtains the current calendar date in system time.
Convenient short-cut for:
SystemClock.inLocalView().now(EthiopianCalendar.axis()). Attention: The Ethiopian calendar changes the date in the morning at 6 AM.- Returns:
- current calendar date in system time zone using the system clock
- Since:
- 3.23/4.19
- See Also:
SystemClock.inLocalView(),ZonalClock.now(net.time4j.engine.Chronology)
-
getEra
Yields the Ethiopian era.
If possible, the era
EthiopianEra.AMETE_MIHRETwill be preferred.- Returns:
- enum
- Since:
- 3.11/4.8
-
getYear
public int getYear()Yields the Ethiopian year.
If possible, the year of era
EthiopianEra.AMETE_MIHRETwill be preferred.- Returns:
- int
- Since:
- 3.13/4.10
-
getMonth
Yields the Ethiopian month.
- Returns:
- enum
- Since:
- 3.11/4.8
-
getDayOfMonth
public int getDayOfMonth()Yields the Ethiopian day of month.
- Returns:
- int
- Since:
- 3.11/4.8
-
getDayOfWeek
Determines the day of week.
The Ethiopian calendar also uses a 7-day-week.
- Returns:
- Weekday
- Since:
- 3.11/4.8
-
getDayOfYear
public int getDayOfYear()Yields the Ethiopian day of year.
- Returns:
- int
- Since:
- 3.11/4.8
-
lengthOfMonth
public int lengthOfMonth()Yields the length of current Ethiopian month in days.
- Returns:
- int
- Since:
- 3.11/4.8
-
lengthOfYear
public int lengthOfYear()Yields the length of current Ethiopian year in days.
- Returns:
- int
- Since:
- 3.11/4.8
-
isLeapYear
public boolean isLeapYear()Is the year of this date a leap year?
- Returns:
- boolean
- Since:
- 3.11/4.8
-
isValid
Queries if given parameter values form a well defined calendar date.
- Parameters:
era- the era to be checkedyearOfEra- the year of era to be checkedmonth- the month to be checkeddayOfMonth- the day of month to be checked- Returns:
trueif valid elsefalse- Since:
- 3.34/4.29
- See Also:
of(EthiopianEra, int, int, int)
-
at
Creates a new local timestamp with this date and given Ethiopian time.
Note: The Ethiopian time will be automatically converted to ISO.
- Parameters:
time- ethiopian time starting in the morning- Returns:
- general timestamp as composition of this date and given time
- Since:
- 3.11/4.8
-
equals
Description copied from class: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.- Overrides:
equalsin classCalendrical<EthiopianCalendar.Unit,EthiopianCalendar>- See Also:
Chronology.getChronoType()
-
hashCode
public int hashCode()Description copied from class:CalendricalBased on the epoch day number.
- Overrides:
hashCodein classCalendrical<EthiopianCalendar.Unit,EthiopianCalendar>
-
toString
Description copied from class: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).
- Specified by:
toStringin classTimePoint<EthiopianCalendar.Unit,EthiopianCalendar>
-
getDefaultWeekmodel
Obtains the standard week model of this calendar.
The Ethiopian calendar usually starts on Sunday.
- Returns:
- Weekmodel
- Since:
- 3.24/4.20
-
axis
Returns the associated time axis.
- Returns:
- chronology
- Since:
- 3.11/4.8
-