swprabhu
7 years agoOccasional Contributor
how to format a date
My input timestamp is in the format "yyyy-mm-dd hh:mm:ss.6additional digits". I need to convert this into the format
"yyyy-mm-dd-hh.mm.ss.6additionaldigits". This has to be done through groovyscripting.
eg : I ran the below code but get an error
def soaprep = "2014-02-11 22:57:12.650224"
def soapform= new Date().parse("yyyy-mm-dd hh:mm:ss.SSSSSS",soaprep)
log.info soapform
def formattime = soapform.format("yyyy-mm-dd-hh.mm.ss.SSSSSS")
log.info formattime
Results (which is not what I expect)
soapform =Sat jan 11 23:08:02 CST 2014
formattime = 2014-08-11-23:08:02.000224
My expected result is 2014-02-11-22.57.12.650224