获取时间戳字符串,直接获取为Long类型
fun getTime(): String {
return System.currentTimeMillis().toString()
}
转换你想要的格式
fun getTime(time: String): String {
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm")
return sdf.format(Date(time.toLong()))
}