ealet
Class Calendar

java.lang.Object
  extended by ealet.Calendar

public class Calendar
extends java.lang.Object

Ethiopian calendar generator including monthly, annual, and moving holidays. It is limited to CE (Common Era); that is, from 00. The calendar calculation, religious and national holidays system is based on Dr. Getatchew Haile's book "Bahra Hassab" published in 2000.

This class can be used for these specific tasks.

Each calendar is generated and organized in a set of linked-list data structure. The following crude figure shows how that structure looks like.
             ---------   ---------   ---------
    Year     |  Sep  |---|  Oct  |---|  Nov  |--- ...
             ---------   ---------   ---------
                 +           +           +
                 |           |           |
                 |           |           |
             ---------   ---------   ---------   -------------
    Date     |  Mon   |   |  Tue  |   |  Thu  |---|  holiday  |....
             ---------   ---------   ---------   -------------
                 .           .           .
                 .           .           .
                 .           .           .
 
Some important terms:

Version:
1.0 October 12, 2005
Author:
abass alamnehe

Constructor Summary
Calendar(int year)
          Constructor: A linked-list for months is constructed.
 
Method Summary
 java.util.LinkedList[] createEthiopianGregorianCalendar()
          This method generates the calendar for the requested year.
static java.lang.String getDay(int month, int date, int ce)
          Returns the day of the given date.
static int getEthiopianDayIndex(int month, int date, int year)
          Determines what the day is for a given Ethiopian date.
 java.util.LinkedList[] getEthiopianGregorianCalendar()
          This method generates the calendar for the requested year.
 java.lang.String getGregorianDay(int ce, int month, int date)
          Returns the day of a given Gregorian date
 int getMetqee(int ce)
          Returns the metqee for the given year
 java.lang.String getNewYearDay(int ce)
          Returns the Ethiopian new year day which will be used as starting day for the given year
 void insertAnnualHoliday()
          The method prepares annual holidays with integer array.
 void insertMonthlyHoliday()
          It prepares monthly holidays with integer array.
 void insertMovingHolidays()
          Fasting holidays are variables since they are calcualted based on moon's epect.
static void main(java.lang.String[] args)
           
static Day toEthiopian(int month, int date, int year)
          The method performs conversion from Gregorian date to Ethiopian.
static Day toEthiopianDate(int gMonth, int gDate, int gYear)
          The method performs conversion from Gregorian date to Ethiopian.
static java.lang.String toEthiopianDateUTF8(int gMonth, int gDate, int gYear)
          This method calls the toEthiopianDat(..) method and converts the result into UTF8 format and return the result.
static java.lang.String toEthiopianDateUTF8(java.lang.String dateSrc)
          This method calls the toEthiopianDat(..) method and converts the result into UTF8 format and return the result.
static Day toGregorian(int month, int date, int year)
          The method performs conversion from Ethiopian date to Gregorian.
static Day toGregorianDate(int eMonth, int eDate, int eYear)
          The method performs conversion from Ethiopian date to Gregorian.
static java.lang.String toGregorianDateUTF8(int gMonth, int gDate, int gYear)
          This method calls the toEthiopianDat(..) method and converts the result into UTF8 format and return the result.
static java.lang.String toGregorianDateUTF8(java.lang.String dateSrc)
          This method calls the toGregorianDat(..) method and converts the result into UTF8 format and return the result.
static int whenIsEthNewYearInGregMonth(int eYear)
          The Ethiopian calendar doesn't follow the modification that was established 1582 by Pop Gregory, because of that the Ethiopian calendar adds three extra days for every four hundred years than needed.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Calendar

public Calendar(int year)
Constructor: A linked-list for months is constructed. *

Parameters:
year - the year to which a calendar will be built
Method Detail

getMetqee

public int getMetqee(int ce)
Returns the metqee for the given year

Parameters:
ce - a year for which metqee is generated
Returns:
metiqee is equal to 30 - abekitee
Since:
2.0

getNewYearDay

public java.lang.String getNewYearDay(int ce)
Returns the Ethiopian new year day which will be used as starting day for the given year

Parameters:
ce - A year for which metqee is generated
Returns:
The name of the first day in String form
Since:
2.0

getDay

public static java.lang.String getDay(int month,
                                      int date,
                                      int ce)
Returns the day of the given date. It starts counting from Tuesday of BCE era 1st day to arrive to the right one.

Parameters:
month - Ethiopian month
date - Ethiopian date
ce - Ethiopian Common Era year
Returns:
The day of the given date in String form
Since:
2.0

insertMonthlyHoliday

public void insertMonthlyHoliday()
It prepares monthly holidays with integer array. It fetches each Date instance and adds the monthly holidays to its list. These holidays will be mapped to proper names by the XMLer class during transformation. For that purpose, the XMLer class utilizes a properties file.

The properties file is "ealet_holiday_properties.xml" and has the following form.

The key and values ares

     1         abo
     ^          ^
    key       value
     ^          ^
     |          |
     |           ----- the name of the holiday
     | 
      ----- the date of the month to the holiday belongs
 

Since:
2.0

insertAnnualHoliday

public void insertAnnualHoliday()
The method prepares annual holidays with integer array. It fetches each Day instance from the calendar and inserts these holidays. The month and date where each annual holiday occurs is used in combination as a key in the holiday properties file and used by the XMLer class during transformation to retrieve the holiday names.

The properties file is "ealet_holiday_properties.xml" and has the following field and value content.

The key and values ares

    1-1     Enkutatash
     ^          ^
    key       value
     ^          ^
     |          |
     |           ----- the name of the holiday
     | 
      ----- the 1st is month while the 2nd is date
 

Since:
2.0

insertMovingHolidays

public void insertMovingHolidays()
Fasting holidays are variables since they are calcualted based on moon's epect. The 1st fasting holiday is Nenewei and it is calculated using metiqee and tewissak. The remaining fasting holidays can be determined based on Nenewei since their ranges are known.

As each fasting holiday is calculated, an instance of the Day class is created and inserted into the calendar under each proper month and date. This method must be called after the main calendar is built; that is. after the calendarYear linked list is completely built. Failing to do so will result fatal error.

Since:
2.0

getGregorianDay

public java.lang.String getGregorianDay(int ce,
                                        int month,
                                        int date)
Returns the day of a given Gregorian date

Parameters:
month - Gregorian calendar month
date - Gregorian calendar date
ce - Gregorian calendar year
Returns:
The name of the day on the given Gregorian date
Since:
2.0

whenIsEthNewYearInGregMonth

public static int whenIsEthNewYearInGregMonth(int eYear)
The Ethiopian calendar doesn't follow the modification that was established 1582 by Pop Gregory, because of that the Ethiopian calendar adds three extra days for every four hundred years than needed. It is assumed that the first Ethiopian new year in CE occured on August 29, 07 of the Western calendar. Until 1582 of Western calendar when an Ethiopian year successeds an Ethiopian leap year, a new year starts on August 30th; otherwise on August 29th. This changed when Pope Gregory modified the Western calendar by shifting October 5, 1582 to October 15, 1582 instantly and introducing a new leap year calculation method. This removed the substantial defects in the calendar; unfortunately, the Ethiopian calendar never adapted the reform, thus its new year continues to shift forward. Note: If the year preceeding any given year is a leap year, in the preceeding year, the month of Paguemain has 6 days instead of 5. In this case, the new year begins one day late than the other years. What this method does is the following a. It calculates the number of leap years until the desired year for Gregorian b. It calculates the number of leap years until the desired year for Ethiopian c. It determines the difference and adds that to August 29 to find out when the new year occurs.

Parameters:
eYear - Ethiopian year
Returns:
The date of September when Ethiopian new year occurs
Since:
2.1

toGregorian

public static Day toGregorian(int month,
                              int date,
                              int year)
The method performs conversion from Ethiopian date to Gregorian. Breifely,

Parameters:
month - Ethiopian calendar month
date - Ethiopian calendar date
year - Ethiopian calendar year
Returns:
Ethiopian day

toEthiopian

public static Day toEthiopian(int month,
                              int date,
                              int year)
The method performs conversion from Gregorian date to Ethiopian. Breifely,

Parameters:
month - Gregorian calendar month
date - Gregorian calendar date
year - Gregorian calendar year
Returns:
Gregorian day

getEthiopianDayIndex

public static int getEthiopianDayIndex(int month,
                                       int date,
                                       int year)
Determines what the day is for a given Ethiopian date. It starts counting from 5500, the number of years in BCE, continuing the BC years. The 1st day starts with "Tuesday".

Parameters:
month - Ethiopian month
date - Ethiopian date
year - Ethiopian year
Returns:
Ethiopian day

toEthiopianDate

public static Day toEthiopianDate(int gMonth,
                                  int gDate,
                                  int gYear)
The method performs conversion from Gregorian date to Ethiopian. Breifely, The following assumptions are made

Parameters:
gMonth - Gregorian calendar month
gDate - Gregorian calendar date
gYear - Gregorian calendar year
Returns:
Ethiopian day
Since:
2.1

toGregorianDate

public static Day toGregorianDate(int eMonth,
                                  int eDate,
                                  int eYear)
The method performs conversion from Ethiopian date to Gregorian. Breifely, The following assumptions are made

Parameters:
eMonth - Gregorian calendar month
eDate - Gregorian calendar date
eYear - Gregorian calendar year
Returns:
Ethiopian day
Since:
2.1

toEthiopianDateUTF8

public static java.lang.String toEthiopianDateUTF8(int gMonth,
                                                   int gDate,
                                                   int gYear)
This method calls the toEthiopianDat(..) method and converts the result into UTF8 format and return the result.

Parameters:
gMonth - Gregorian calendar month
gDate - Gregorian calendar date
gYear - Gregorian calendar year
Returns:
Ethiopian day
Since:
2.1

toGregorianDateUTF8

public static java.lang.String toGregorianDateUTF8(java.lang.String dateSrc)
This method calls the toGregorianDat(..) method and converts the result into UTF8 format and return the result.

Parameters:
dateSrc - Ethiopian date in String type
Returns:
Ethiopian day in String type
Since:
2.1

toEthiopianDateUTF8

public static java.lang.String toEthiopianDateUTF8(java.lang.String dateSrc)
This method calls the toEthiopianDat(..) method and converts the result into UTF8 format and return the result.

Parameters:
dateSrc - Gregorian date in String type
Returns:
Ethiopian day in String type
Since:
2.1

toGregorianDateUTF8

public static java.lang.String toGregorianDateUTF8(int gMonth,
                                                   int gDate,
                                                   int gYear)
This method calls the toEthiopianDat(..) method and converts the result into UTF8 format and return the result.

Parameters:
gMonth - Gregorian calendar month
gDate - Gregorian calendar date
gYear - Gregorian calendar year
Returns:
Ethiopian day
Since:
2.1

getEthiopianGregorianCalendar

public java.util.LinkedList[] getEthiopianGregorianCalendar()
This method generates the calendar for the requested year. It involves a serious of steps. Finally, it returns an array of a linked list consisting of the calendar.

Since:
2.0

createEthiopianGregorianCalendar

public java.util.LinkedList[] createEthiopianGregorianCalendar()
This method generates the calendar for the requested year. It involves a serious of steps. Finally, it returns an array of a linked list consisting of the calendar.

Since:
2.0

main

public static void main(java.lang.String[] args)