mirror of
https://github.com/gkd-kit/gkd.git
synced 2024-11-16 03:32:38 +08:00
perf: format cache
This commit is contained in:
parent
8822eddc2f
commit
b78660d60c
|
@ -3,6 +3,7 @@ package li.songe.gkd.util
|
|||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.collections.hashMapOf
|
||||
|
||||
fun formatTimeAgo(timestamp: Long): String {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
|
@ -25,7 +26,7 @@ fun formatTimeAgo(timestamp: Long): String {
|
|||
}
|
||||
}
|
||||
|
||||
private val formatDateMap = mutableMapOf<String, SimpleDateFormat>()
|
||||
private val formatDateMap by lazy { hashMapOf<String, SimpleDateFormat>() }
|
||||
|
||||
fun Long.format(formatStr: String): String {
|
||||
var df = formatDateMap[formatStr]
|
||||
|
|
Loading…
Reference in New Issue
Block a user