Use LocalDate.ofInstant()

This commit is contained in:
Isira Seneviratne 2023-07-26 05:29:34 +05:30
parent c7c3d87ee5
commit 3dc29b1983

View File

@ -64,9 +64,7 @@ object TextUtils {
} }
fun formatRelativeDate(context: Context, unixTime: Long): CharSequence { fun formatRelativeDate(context: Context, unixTime: Long): CharSequence {
// TODO: Use LocalDate.ofInstant() when it is available in SDK 34. val date = LocalDate.ofInstant(Instant.ofEpochMilli(unixTime), ZoneId.systemDefault())
val date = LocalDateTime.ofInstant(Instant.ofEpochMilli(unixTime), ZoneId.systemDefault())
.toLocalDate()
val now = LocalDate.now() val now = LocalDate.now()
val months = date.until(now, ChronoUnit.MONTHS) val months = date.until(now, ChronoUnit.MONTHS)