Question

I created a database for georgian date only. In my android application's home page I want to display both georgian and hijri dates (islamic). How can I write the hijri code?

My georgian code is

void getDate()
{
    Date d=new Date();
    CharSequence s  = DateFormat.format("EEEE, MMMM d, yyyy", d.getTime());
    miladiView.setText(s);// the name of the field that displays georgian date 
}
Était-ce utile?

La solution

You can use the IslamicChronology from Joda.org (http://www.joda.org/joda-time/cal_islamic.html). Though not sure how accurate they're doing it, since Hijri date (for example in Saudi) is based on moon sighting (not pure mathematical calculation), which can even differ between different Muslim countries.

An example from the aforementioned source:

// setup date object for midday on May Day 2004 (ISO year 2004)
DateTime dtISO = new DateTime(2004, 5, 1, 12, 0, 0, 0);

// find out what the same instant is using the Islamic Chronology
DateTime dtIslamic = dtISO.withChronology(IslamicChronology.getInstance());
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top