ealet
Class Calendar
java.lang.Object
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.
-
To generate annual Ethioian calendar
Calendar cal = new Calendar(year) ;
-
To convert from Ethiopian date to Gregorian
Day date = Calendar.toGregorianDate(month, date, year) ;
Day date = Calendar.toGregorianDateUTF(month, date, year) ;
Day date = Calendar.toGregorianDateUTF(gregorianDate) ;
-
To convert from Gregorian date to Ethiopian
Day date = Calendar.toEthiopianDate(gMonth, gDate, gYear) ;
Day date = Calendar.toEthiopianDateUTF(gMonth, gDate, gYear) ;
Day date = Calendar.toEthiopianDateUTF(ethiopianDate) ;
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:
-
abekitee refers to the difference or overlapping days between Lunar and
Solar calendar. Lunar's calendar year is shorter than Solar's by 11 days and this
number increases every year. The Ethiopian Orthodox Church calculates its some of
fasting holidays based on lunar calendar year. In the process, when the
difference reaches over the 30 days, it is modulated by 30 and the result is used.
-
metqee is the number of days it takes for Lunar month to complete
when it is overlapped with the beginning month of new year. metiqee
is calculated by subtracting abekitte from 30. If the result is equal or less than
to 8, metqee is said to occur in October; otherwise, in September
-
Tintyon is a system by which one can determine the first day of each
month if one is known. For instance, if the 1st day of September is
Monday, April's 1st day will occur Monday and January's on Tuesday.
-
CE (Common Era) is used in place of AD (anno Domini)
-
BCE (Before Common Era) is used in place of BC (before Christ)
- 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 |
Calendar
public Calendar(int year)
- Constructor: A linked-list for months is constructed. *
- Parameters:
year
- the year to which a calendar will be built
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 monthdate
- Ethiopian datece
- 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 monthdate
- Gregorian calendar datece
- 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,
- Determines when Ethiopian new years occurs in Greg. September
- Initially, converts Eth year to Greg using the 7 years diff
- If Eth date falls after Dec, the Greg year must be up by 1 year
- Since the Eth new year is on September, its overlaps with Gregorian;
thus to calculate the Greg month an order is introduced
- Once the Greg date is found, the day is easily obtained
- Parameters:
month
- Ethiopian calendar monthdate
- Ethiopian calendar dateyear
- 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,
- Determines when Ethiopian new years occurs in Greg. September
- Initially, converts Greg year to Eth using the 8 years diff
- If the Greg date falls after Eth new year, the Eth year must be up by 1
year
- Since the Eth new year is on August||September||?, it overlaps with Gregorian;
thus to calculate the Greg month an order is introduced
- Then the Eth month and date are determined
- Parameters:
month
- Gregorian calendar monthdate
- Gregorian calendar dateyear
- 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 monthdate
- Ethiopian dateyear
- 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,
- Determines when Ethiopian new years occurs in Greg.
- Initially, converts Greg year to Eth using the 8 years diff
- If the Greg date falls after Eth new year, the Eth year must be up by 1
year
- Since the Eth new year is on August||September||?, it overlaps with Gregorian;
thus to calculate the Greg month an order is introduced
- Then the Eth month and date are determined
The following assumptions are made
- In CE, the first Tahissas matches December 25.
- Conversion is allowed for Gregorian dates starting from 1/1/9.
- Dates from 10/05/1582 to 10/14/1582 are ignored.
- Julian method is used for leap years calcualtion until 10/04/1582, then Gregorian method.
- Ethiopina calendar adds a leap year to a year when it is module 4 with result 3.
- Parameters:
gMonth
- Gregorian calendar monthgDate
- Gregorian calendar dategYear
- 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,
- Determines when Eth new years occurs in Gregorianr
- Initially, converts Eth year to Greg using the 7 years diff
- If the Eth date falls after Greg new year, the difference between Eth and Greg is 8 years
- The Eth new year occurs in August||September||? and it is determined by calculating the
leap years of both Eth and Greg, finding the difference, and adding the result to
the number of dates between the original Jan 1 and Meskerem 1.
- Then the Greg month and date are determined
The following assumptions are made
- In CE, the first Tahissas matches December 25.
- Conversion is allowed for Gregorian dates starting from 1/1/9.
- Dates from 10/05/1582 to 10/14/1582 in Greg are ignored.
- Julian method is used for leap years calcualtion until 10/04/1582, then Gregorian method.
- Ethiopina calendar adds a leap year to a year when it is module 4 with result 3.
- Parameters:
eMonth
- Gregorian calendar montheDate
- Gregorian calendar dateeYear
- 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 monthgDate
- Gregorian calendar dategYear
- 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 monthgDate
- Gregorian calendar dategYear
- 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.
- Determins the 1st day of both the Eth and Greg year
- Generates the equivalent Greg year for Eth
- If Greg leap year, March will have 29 days
- Using linked list for months and days, calendar is built
- Updates the calendar by adding holidays, and fasting holidays
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.
- Determins the 1st day of both the Eth and Greg year
- Generates the equivalent Greg year for Eth
- If Greg leap year, March will have 29 days
- Using linked list for months and days, calendar is built
- Updates the calendar by adding holidays, and fasting holidays
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)