cancel
Showing results for 
Search instead for 
Did you mean: 

Ready API 3.3.1 - messed date up

SOLVED
Highlighted
Occasional Contributor

Ready API 3.3.1 - messed date up

I just updated my SoapUI to 3.3.1 and now my Groovy dates don't work.  I keep getting errors "groovy.lang.MissingMethodException: No signature of method: java.util.Date.format() ..."  Has anyone else had this and do they have a fix?  To recreate I have 2 different ways:

1. in a Groovy script:  String todaysDate = new Date().format("YYYYMMdd")

2. in XML injection ${new Date().format("YYYYMMdd")}

 

Everything was running fine.  I did the update, made no changes and now this doesn't work.  I'm going back to 3.3.0 for now due to this is a complete stop for me.

 

I appreciate any help someone can provide.

15 REPLIES 15
Highlighted
Community Hero

Right.


Regards,
Rao.
Occasional Contributor

@nmrao - Thanks for your time and patience in this date thing.  

 

I also wanted to note, that if anyone is just using the date and doesn't need anything to do with time you can use the following code:

XML:

${java.time.LocalDate.now()}  This will default to the format YYYY-MM-dd

 

Groovy: 

if you use the "Import java.time.*" then you just need LocalDate.now(), otherwise java.time.LocalDate.now() will give the same format as above XML.

 

To use a different format you will need to setup a format variable or put it all together as @nmrao has shown previously.

 

This link helped me play around and get it working:  https://www.java67.com/2016/10/how-to-parse-string-to-localdate-in-Java8-DateTimeFormatter-Example.h...

 

Hope this helps. Good luck!  😉

Highlighted
New Contributor

a piece of code in groovy which was working fine up to ReadyAPI version 3.2.5

Once I have updated the version, the format () function stopped working.

Can anyone suggest how I can manipulate the date? Like, I want a random date after 6 months from today.

 

Upto ReadyAPI 3.2.5 I have used - 

use(TimeCategory) {
def date = (today + (new Random().nextInt(12)).months).format(yyyy-MM-DD).toString());

}

But the format () function not working in ReadyAPi 3.3.1. Any leads would be appreciated.

 

Thanks in advance!

Highlighted
Contributor

Hi @API_Guy 

 

Can you please try below snippet

 

import groovy.time.TimeCategory
import java.text.SimpleDateFormat

 

use(TimeCategory) {
date = ((new Date() + (new Random().nextInt(12)).months))
sdf = new SimpleDateFormat("yyyy-MM-dd")
newDate = sdf.format(date)
}

 

Thanks!

 

Highlighted
New Contributor

Thanks much, @Redde.

It worked for me and it was a great help! thanks again.

@khanchett this is how you can manipulate the date by adding or subtracting a day/month as well

date = ((new Date() +  3.months). you can give a try. It worked for me.

Highlighted
Visitor

Hi Smart Bear Team ,

 

 

 

 Thanks for this Solution but this solution works only when we change the Script and it is very difficult to change every script in each and every Automation Pack let say suppose  60 Automation pack  around 30 Script in Generate Test Data and Grooy script 

 

That would be very very difficult to change the script to fix this issue 

So we want proper solution like in change in Jar file or some classes change so it should be one time change / one time activity  to fix this issue

 

we are using Pro Version and need it to fix other wise we wont be able to continue to next level of version 

 

 

Tags (1)
New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors