android格式化日期

import android.text.format.DateFormat
import java.util.*

dateTextView.text = DateFormat.format("yyyy MM dd ,EEEE, h:mmaa", crime.date)//格式化日期

informat参数是一个想要变成的格式

参考如下;

For the month of September:
M -> 9
MM -> 09
MMM -> Sep
MMMM -> September

For 7 minutes past the hour:
m -> 7
mm -> 07
mmm -> 007
mmmm -> 0007

Examples for April 6, 1970 at 3:23am:
"MM/dd/yy h:mmaa" -> "04/06/70 3:23am"
"MMM dd, yyyy h:mmaa" -> "Apr 6, 1970 3:23am"
"MMMM dd, yyyy h:mmaa" -> "April 6, 1970 3:23am"
"E, MMMM dd, yyyy h:mmaa" -> "Mon, April 6, 1970 3:23am&
"EEEE, MMMM dd, yyyy h:mmaa" -> "Monday, April 6, 1970 3:23am"
"'Noteworthy day: 'M/d/yy" -> "Noteworthy day: 4/6/70"

 

yyyyMMddHHmmssSSS 年月日时分秒毫秒

 

posted @ 2021-05-18 17:02  ou尼酱~~~  阅读(217)  评论(0)    收藏  举报