mohamed rejeb
09/28/2024, 2:32 PMDatePicker
always shows in UTC time regardless of the local timezone. Anyone encountered this issue before?Abhimanyu
09/28/2024, 3:04 PMdatePickerState.selectedDateMillis
Abhimanyu
09/28/2024, 3:06 PMval startOfDayTimestamp: LocalDate = getLocalDate(
timestamp = datePickerState.selectedDateMillis.orZero(),
)
Util methods I use,
You can combine them into a single one if required.
public fun getLocalDate(
timestamp: Long,
zoneId: ZoneId = getSystemDefaultZoneId(),
): LocalDate {
return Instant
.ofEpochMilli(timestamp)
.toZonedDateTime(
zoneId = zoneId,
)
.toLocalDate()
}
public fun Instant.toZonedDateTime(
zoneId: ZoneId = getSystemDefaultZoneId(),
): ZonedDateTime {
return this.atZone(zoneId)
}
public fun getSystemDefaultZoneId(): ZoneId {
return ZoneId.systemDefault()
}