I want to convert the date from dd-mm-yy to yy-mm-dd in scala, but I am having issues to make it happen
val format = new java.text.SimpleDateFormat("dd-mm-yyyy")
format.format(new java.util.Date())
output:
res0: String = 06-07-2018
but if I want to change the format to yy-mm-dd:
val format = new java.text.SimpleDateFormat("yy-mm-dd")
format.format(new java.util.Date())
output:
res2: String = 18-41-06
what did I do wrong? why the mm comes out as 41?
The correct format is
val format = new java.text.SimpleDateFormat("yyyy-MM-dd")
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments