I want to localise a date in Kotlin Android, so that when I change language I see date accordingly
Date coming through is : Tue Feb 06 00:00:00 GMT 2024
What I want to get is
Italian - lun 5 feb
German - Mo. 5. Feb.
Android system should do this
what I have got so far
private fun testFun(date: Date): String {
val fullDateFormatter: DateTimeFormatter = DateTimeFormatter.ofPattern("EEE d MMM")
return date.toLocalDate(timeZoneId).format(fullDateFormatter)
}
fun Dates.toLocalDate(timeZoneId: ZoneId): LocalDate {
return java.time.Instant.ofEpochMilli(time).atZone(timeZoneId).toLocalDate()
}
to LocalDate time is wrong as it returns me Mar 5 Feb
please suggest how I can achieve this
thanks R