Skip to content

Commit 7b6c3a1

Browse files
authored
Merge pull request #823 from ahmed-madhoun1/allow_localised_date_format
Allow localised date format
2 parents b2a74ba + 3114b2e commit 7b6c3a1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

core/ui/src/main/java/com/google/samples/apps/nowinandroid/core/ui/NewsResourceCard.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import kotlinx.datetime.Instant
7070
import kotlinx.datetime.toJavaInstant
7171
import java.time.ZoneId
7272
import java.time.format.DateTimeFormatter
73+
import java.time.format.FormatStyle
7374
import java.util.Locale
7475
import com.google.samples.apps.nowinandroid.core.designsystem.R as DesignsystemR
7576

@@ -230,8 +231,11 @@ fun dateFormatted(publishDate: Instant): String {
230231
}
231232
}
232233

233-
return DateTimeFormatter.ofPattern("MMM d, yyyy")
234-
.withZone(zoneId).format(publishDate.toJavaInstant())
234+
return DateTimeFormatter
235+
.ofLocalizedDate(FormatStyle.MEDIUM)
236+
.withLocale(Locale.getDefault())
237+
.withZone(zoneId)
238+
.format(publishDate.toJavaInstant())
235239
}
236240

237241
@Composable

0 commit comments

Comments
 (0)