Equator
Equator

Reputation: 87

Date converstion in Groovy

In groovy I was using below to generate date in the format "2020-09-14T06:00:00Z" in Ready API 3.3.1

def today = new Date()
return today.format("yyyy-MM-dd") + "T" + today.format("HH:mm:ss") +".000Z" 

After updating to 3.3.2 It's giving me an error

groovy.lang.MissingMethodException: No signature of method: java.util.Date.format()
   is applicable for argument types: (String) values: [yyyy-MM-dd].

Could someome help

Upvotes: 0

Views: 623

Answers (1)

Jeff Scott Brown
Jeff Scott Brown

Reputation: 27245

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>

Upvotes: 1

Related Questions