Merge pull request #823 from ahmed-madhoun1/allow_localised_date_format

Allow localised date format
pull/838/head
Milosz Moczkowski 1 year ago committed by GitHub
commit 7b6c3a16ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -70,6 +70,7 @@ import kotlinx.datetime.Instant
import kotlinx.datetime.toJavaInstant import kotlinx.datetime.toJavaInstant
import java.time.ZoneId import java.time.ZoneId
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
import java.time.format.FormatStyle
import java.util.Locale import java.util.Locale
import com.google.samples.apps.nowinandroid.core.designsystem.R as DesignsystemR import com.google.samples.apps.nowinandroid.core.designsystem.R as DesignsystemR
@ -230,8 +231,11 @@ fun dateFormatted(publishDate: Instant): String {
} }
} }
return DateTimeFormatter.ofPattern("MMM d, yyyy") return DateTimeFormatter
.withZone(zoneId).format(publishDate.toJavaInstant()) .ofLocalizedDate(FormatStyle.MEDIUM)
.withLocale(Locale.getDefault())
.withZone(zoneId)
.format(publishDate.toJavaInstant())
} }
@Composable @Composable

Loading…
Cancel
Save