更新代码
This commit is contained in:
@@ -46,4 +46,18 @@ fun Date.formatPostTime(): String {
|
||||
SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
||||
}
|
||||
return dateFormat.format(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* YYYY.DD.MM HH:MM
|
||||
*/
|
||||
fun Date.formatPostTime2(): String {
|
||||
val calendar = Calendar.getInstance()
|
||||
calendar.time = this
|
||||
val year = calendar.get(Calendar.YEAR)
|
||||
val month = calendar.get(Calendar.MONTH) + 1
|
||||
val day = calendar.get(Calendar.DAY_OF_MONTH)
|
||||
val hour = calendar.get(Calendar.HOUR_OF_DAY)
|
||||
val minute = calendar.get(Calendar.MINUTE)
|
||||
return "$year.$month.$day $hour:$minute"
|
||||
}
|
||||
Reference in New Issue
Block a user