0

I need to find the 14days from today, but I need the format as [yyyy-MM-dd]

def laterday = new Date() + 14
message.setProperty("laterday",laterday.format("yyyy-MM-dd"))

I'm doing the validation as below

xmlData.Emp.findAll{
    (Date.parse("yyyy-MM-dd",it.startDate.text().substring(0,10))) < (Date.parse("yyyy-MM-dd",laterday))                        
}.each{                     
    it.replaceNode{}
} 

**

Getting below error:

No signature of method: static java.util.Date.parse() is applicable for argument types: (java.lang.String, java.util.Date) values: [yyyy-MM-dd, Sat Sep 26 06:02:18 UTC 2020] Possible solutions: parse(java.lang.String), parse(java.lang.String, java.lang.String), parse(java.lang.String, java.lang.String, java.util.TimeZone), wait(), clone(), grep()

I need to change the date format to [2020-09-26], can someone help on this.?

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
  • Does this answer your question? [Groovy String to Date](https://stackoverflow.com/questions/3817862/groovy-string-to-date) – cfrick Sep 12 '20 at 13:22

1 Answers1

0

No signature of method: static java.util.Date.parse() is applicable for argument types: (java.lang.String, java.util.Date) values: [yyyy-MM-dd, Sat Sep 26 06:02:18 UTC 2020] Possible solutions: parse(java.lang.String), parse(java.lang.String, java.lang.String), parse(java.lang.String, java.lang.String, java.util.TimeZone), wait(), clone(), grep()

In recent versions of Groovy the Date extension methods have been moved to their own library, which you will have to add to your project. For example, if you are using Gradle as your build tool, you may want something like this:

compile group: 'org.codehaus.groovy', name: 'groovy-dateutil', version: '3.0.5'

If using Maven:

<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-dateutil</artifactId>
    <version>3.0.5</version>
</dependency>
Jeff Scott Brown
  • 26,804
  • 2
  • 30
  • 47