1

I have this code for my App, where I wanted a date like "06 Ramadan 1441" to show for 29.04.2020 but when I changed the date to 3.4.2021 and checked it with "https://www.islamicity.org/hijri-gregorian-converter/index.php?address=undefined#" it says 20.Shaban.1442 but my app says 21.Shaban.1442

String hij_date = HijrahDate.now().toString();
int date_len = hij_date.length();
String d = hij_date.substring(date_len - 2, date_len);
String m = hij_date.substring(date_len - 5, date_len - 3);
String y = hij_date.substring(date_len - 10, date_len - 6);
textView.setText(d + " " + monthname(m) + " " + y);
textView.setTypeface(null, Typeface.BOLD);

Thank you for your help.

Visonge
  • 99
  • 8
  • [My recent post](https://stackoverflow.com/a/61508728/2491410) describes in short how different Java libraries handle date conversion. There are different versions of Islamic calendar. Maybe you use ThreetenABP on Android (my speculation). This library has a different date conversion than for example standard Java (in package `java.time.chrono`). – Meno Hochschild Apr 30 '20 at 11:44

1 Answers1

2

I think the problem is not in the library. Hijra dates are not like regular dates, they are determined by moon and not the sun. And there is a debate on how date should be set. Some people started Ramandan on 24 April while others started on 25 April.

Hadi Haidar
  • 337
  • 2
  • 13
  • While you have correctly recognized that there are different versions of Islamic calendar, one thing is strange. I speculate that the OP uses ThreetenABP which promises to be a backport of `java.time` but has not adopted the implementation of `java.time.chrono.HijrahDate`. Historical reason is that Oracle had changed the Hijri calendar short before release of Java-8, and the change was not backported. – Meno Hochschild Apr 30 '20 at 11:55