Added Long.toUtcTime function in FunctionFactory

This commit is contained in:
2022-10-02 00:46:38 +08:00
parent 1862faf637
commit bfb5e037e5

View File

@@ -52,6 +52,8 @@ import com.topjohnwu.superuser.Shell
import java.io.Serializable
import java.math.RoundingMode
import java.text.DecimalFormat
import java.text.SimpleDateFormat
import java.util.*
/**
* 系统深色模式是否开启
@@ -210,6 +212,12 @@ fun Number.decimal(count: Int = 2) = runCatching {
).apply { roundingMode = RoundingMode.HALF_UP }.format(this) ?: toString()
}.getOrNull() ?: this
/**
* [Long] 转换为 UTC 时间
* @return [String]
*/
fun Long.toUtcTime() = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.ROOT).format(Date(this)) ?: ""
/**
* 弹出 [Toast]
* @param msg 提示内容