Forum Discussion

ATokeley's avatar
ATokeley
Contributor
15 years ago

Converting Date string into Date

Hi guys,
I'm pulling my hair out trying to convert a string of format (2007-01-26T00:00:00) being returned in a REST response into a date format so I can operate on it and then re-use the value to perform a search.

def newdate = new Date().parse("d/M/yyyy H:m:s",lastDate)

I get the following :
groovy.lang.MissingMethodException: No signature of method: java.util.Date.parse() is applicable for argument types: (java.lang.String, groovy.util.slurpersupport.NodeChildren) values: [d/M/yyyy H:m:s, 2007-01-26T00:00:00] Possible solutions: parse(java.lang.String), parse(java.lang.String, java.lang.String), wait(), clone(), any(), use([Ljava.lang.Object;)

Cheers,
- Richard

2 Replies

  • Hi!

    maybe you need to call lastDate.toString() ?

    If that doesn't help can you show your entire script to help us debug this ?

    regards!

    /Ole
    eviware.com
  • Yup, you're on the right track- it was something to do with the type string was being returned as!