所以我有dd/mm/yyyy
日期格式,我想将其转换为日期dd MMM, yyyy
格式。这是我尝试过的:
val s: String = "27/04/2014"
val simpleDateFormat: SimpleDateFormat = new SimpleDateFormat("dd/mm/yyyy")
val date2 = simpleDateFormat.parse(s)
val df = new SimpleDateFormat("dd MMM, yyyy")
println(df.format(date2))
结果:
27 Jan, 2014 res0: Unit = ()
改变
val simpleDateFormat: SimpleDateFormat = new SimpleDateFormat("dd/mm/yyyy")
到
val simpleDateFormat: SimpleDateFormat = new SimpleDateFormat("dd/MM/yyyy")
查看所有代码:http : //developer.android.com/reference/java/text/SimpleDateFormat.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句