Material3 `DatePicker` always shows in UTC time re...
# compose
m
Material3
DatePicker
always shows in UTC time regardless of the local timezone. Anyone encountered this issue before?
🚫 1
a
Can you share more about the issue? This returns the selected date timestamp
Copy code
datePickerState.selectedDateMillis
I use this to get the date timestamp with timezone.
Copy code
val startOfDayTimestamp: LocalDate = getLocalDate(
                            timestamp = datePickerState.selectedDateMillis.orZero(),
                        )
Util methods I use, You can combine them into a single one if required.
Copy code
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()
}