Reputation: 1280
So i have dd/mm/yyyy
date format and i want to convert it into date dd MMM, yyyy
format.
This is what i have try:
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))
Result:
27 Jan, 2014 res0: Unit = ()
Upvotes: 1
Views: 116
Reputation: 1718
change the
val simpleDateFormat: SimpleDateFormat = new SimpleDateFormat("dd/mm/yyyy")
to
val simpleDateFormat: SimpleDateFormat = new SimpleDateFormat("dd/MM/yyyy")
check this out for all the codes: http://developer.android.com/reference/java/text/SimpleDateFormat.html
Upvotes: 2