i have this function to get date:
fun getDate() {
var hijriMonths = resources.getStringArray(R.array.hijri_months)
val dateFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("dd-MM-uuuu")
var sdf = SimpleDateFormat("dd-MM-yyyy",Locale.ENGLISH)
val c = Calendar.getInstance()
try {
c.time = sdf.parse(currentDate("dd-MM-yyyy"))
} catch (e: ParseException) {
e.printStackTrace()
}
c.add(
Calendar.DATE,
viewModel.days_changed
)
var _date: String = sdf.format(c.time)
val gregorianDate: LocalDate = LocalDate.parse(_date, dateFormatter)
val islamicDate: HijrahDate = HijrahDate.from(gregorianDate)
islamic_date.text = islamicDate.get(ChronoField.DAY_OF_MONTH).toString()+" "+hijriMonths[islamicDate.get(
ChronoField.MONTH_OF_YEAR
) - 1]+" "+islamicDate.get(ChronoField.YEAR) +getString(R.string.hijriSign)
sdf = SimpleDateFormat("dd MMMM yyyy", Locale.ENGLISH)
try {
c.time = sdf.parse(currentDate("dd MMMM yyyy"))
} catch (e: ParseException) {
e.printStackTrace()
}
c.add(
Calendar.DATE,
viewModel.days_changed
)
_date = sdf.format(c.time)
var day_name = SimpleDateFormat("EEEE", Locale.ENGLISH).format(c.time)
date.text = _date
day.text = day_name
}
I'm getting these dates which is correct but the only wrong thing about it is the day of the Islamic date (it add one day) supposed to be 2 no 3 Muharram
what did i do wrong here?