java - How to convert a String into DateTime format? -


i have "may 07, 2015" string. want convert datetime format 2015-05-07 pattern .
have converted follows:

scala> val format = new java.text.simpledateformat("mmm dd, yyyy") format: java.text.simpledateformat = java.text.simpledateformat@2e2b536d  scala> format.parse("may 07 2015") res5: java.util.date = thu may, 07 00:00:00 ist 2015 

what should next step convert above int 2015-05-07 without writing map convert months corresponding numeric values?

because use simpledateformat why do't use second dateformat format date, e.g.

val df = new java.text.simpledateformat("yyyy-mm-dd") df.format(*date*) 

to complete example:

val format = new java.text.simpledateformat("mmm dd yyyy") val mydate = format.parse("may 07 2015") val df = new java.text.simpledateformat("yyyy-mm-dd") df.format(mydate) 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -