Class EthiopianCalendar

All Implemented Interfaces:
Serializable, Comparable<EthiopianCalendar>, CalendarDate, ChronoDisplay, Temporal<CalendarDate>, LocalizedPatternSupport

@CalendarType("ethiopic") public final class EthiopianCalendar extends Calendrical<EthiopianCalendar.Unit,​EthiopianCalendar> implements 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

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
  • Field Details

  • 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 era
      yearOfEra - Ethiopian year of era in the range 1-9999 (1-15499 if amete alem)
      month - Ethiopian month
      dayOfMonth - 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

      public static EthiopianCalendar of(EthiopianEra era, int yearOfEra, int month, int dayOfMonth)

      Creates a new instance of an Ethiopian calendar date.

      Parameters:
      era - Ethiopian era
      yearOfEra - Ethiopian year of era in the range 1-9999 (1-15499 if amete alem)
      month - Ethiopian month in the range 1-13
      dayOfMonth - 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

      public static EthiopianCalendar 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

      public EthiopianEra getEra()

      Yields the Ethiopian era.

      If possible, the era EthiopianEra.AMETE_MIHRET will 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_MIHRET will be preferred.

      Returns:
      int
      Since:
      3.13/4.10
    • getMonth

      public EthiopianMonth 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

      public Weekday 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

      public static boolean isValid(EthiopianEra era, int yearOfEra, int month, int dayOfMonth)

      Queries if given parameter values form a well defined calendar date.

      Parameters:
      era - the era to be checked
      yearOfEra - the year of era to be checked
      month - the month to be checked
      dayOfMonth - the day of month to be checked
      Returns:
      true if valid else false
      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

      public boolean equals(Object obj)
      Description copied from class: Calendrical

      Based 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:
      equals in class Calendrical<EthiopianCalendar.Unit,​EthiopianCalendar>
      See Also:
      Chronology.getChronoType()
    • hashCode

      public int hashCode()
      Description copied from class: Calendrical

      Based on the epoch day number.

      Overrides:
      hashCode in class Calendrical<EthiopianCalendar.Unit,​EthiopianCalendar>
    • toString

      public String toString()
      Description copied from class: TimePoint

      Provides 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:
      toString in class TimePoint<EthiopianCalendar.Unit,​EthiopianCalendar>
    • getDefaultWeekmodel

      public static Weekmodel 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