Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get correct current islamic date

Tags:

java

jodatime

i am using joda time to get current islamic date in Saudi Arabia as in their website:

DateTime dtISO = new DateTime(2014, 1, 9, 0, 0, 0, 0);
DateTime dtIslamic = dtISO.withChronology(IslamicChronology.getInstance());

above prints the day less than the actual day, it prints that today is 7 but actual is 8. please advise.

UPDATE:

i even tried it with timezone as follows:

DateTimeZone SAUDI_ARABIA = DateTimeZone.forID("Asia/Riyadh");
DateTime dtISO = new DateTime(2014, 1, 9, 0, 0, 0, 0);
DateTime dtIslamic = dtISO.withChronology(IslamicChronology.getInstance(SAUDI_ARABIA));

but it gives same result.

like image 451
Mahmoud Saleh Avatar asked Jan 09 '14 15:01

Mahmoud Saleh


People also ask

What is today's date in Islam?

Muharram, it is wednesday 10 shawwal 1443. Gregorian todays date in islam for 2022 - 4 shawwal 1443. Much of shawwal 1443 in uk and corresponding to islamic calendar is 10 shawwal 1443 or muslim calendar, ramadan 1443.

What Arabic month is today?

Islamic date today in India is 10 Rabi al-Akhir 1444 as on November 06, 2022.

What is Islamic date in India today?

Today Islamic Date is 09 Rabi Al-Akhar 1444 on international date 05 Nov, 2022. Islamic date is also called Hijri Date or Arabic date in the Muslim world that follows Moon phases as a lunar calendar.

What is today's Islamic date in Nigeria?

Today's date is Tuesday 6th Rabi'ul Thani 1444H /1st November 2022. Today's date is Monday 5th Rabi'ul Thani 1444H /31st October 2022.


1 Answers

First I have experimented with JodaTime's "leap-year-pattern". All four defined patterns yield the same result, namely the date "Hijrah 1435-03-07". Here my test code:

DateTime dtISO = new DateTime(2014, 1, 9, 0, 0, 0, 0);
DateTimeZone tzSAUDI_ARABIA = DateTimeZone.forID("Asia/Riyadh");
DateTime dtIslamic = 
  dtISO.withChronology(
    IslamicChronology.getInstance(
      tzSAUDI_ARABIA, 
      IslamicChronology.LEAP_YEAR_15_BASED));
System.out.println(dtIslamic);

According to the website islamicfinder.org the date should indeed be:

Thursday 8 Raby` al-awal 1435 A.H.

Or see: http://www.ummulqura.org.sa/

We have to memorize here that Joda Time only supports islamic calendar based on an algorithmic calculation using a special leap year pattern. All in all I know of 8 such patterns. Joda Time defines four of them. What Joda Time does not support is the official calendar of Saudi-Arabia, namely Umalqura calendar which is a sighting based calendar. So as summary we can say: Using Joda Time is no option for Saudi-Arabia. What to do now?

One option is using com.ibm.icu.util.IslamicCalendar as @PopoFibo has mentioned. The other option would be currently waiting for Java 8 which contains Umalqura calendar which is not necessary the same as the IBM version. In detail: While the IBM version is still based on calculations (either "astronomical" (not really) or "civil") the class java.time.chrono.HijrahDate uses a background lookup table with data given by saudi-arabian agency KACST. I would trust this version far more than the IBM version because for other dates IBM (here its library ICU4J) is not necessarily correct. So in Java 8 you could use:

HijrahDate hdate = 
  HijrahChronology.INSTANCE.date(LocalDate.of(2014, Month.JANUARY, 9));
System.out.println(hdate); // Output: "Hijrah-umalqura AH 1435-03-08"
like image 83
Meno Hochschild Avatar answered Sep 29 '22 17:09

Meno Hochschild