Android: how to get Islamic/Hijrah date for India

35 views Asked by At

I want to get the Hijrah date based on India location, right now I can get the Hijrah date for Saudi Arabia using ummul qura calendar, but I want to get the hijrah date for India

here is the code I am using for now

@RequiresApi(Build.VERSION_CODES.O)
private fun getHijriDate() {
    bindAddSalahTime.islamicDateLl.visibility = View.VISIBLE
    val hijriDate = HijrahDate.now()
    val todayHijriDateStr = DateTimeFormatter.ofPattern("dd-MMMM-yyyy").format(hijriDate)
    val day = DateTimeFormatter.ofPattern("MM").format(hijriDate)
    bindAddSalahTime.islamicDateTv.text =
        StringBuilder(todayHijriDateStr).insert(todayHijriDateStr.length - 5, "($day)")
}

Any help is appreciated

1

There are 1 answers

0
Mohd Qasim On

As we know HijrahDate will return Saudi Arabia date, and India will run behind one day to Saudi Arabia (in islamic dates) so we can minus one day from the Hijrah date, following is the snippet of the code.

val hijriDate = HijrahDate.now().minus(1, ChronoUnit.DAYS)