Ask a Question

Ready API 3.3.1 - messed date up

SOLVED
khanchett
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.

16 REPLIES 16

Right.


Regards,
Rao.

@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!  😉

API_Guy
Occasional 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!

PrathapR
Frequent 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!

 

API_Guy
Occasional Contributor

Thanks much, @PrathapR.

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.

ank2555
Regular 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 

 

 

scierniak
Occasional Contributor

 

FYI, I faced same issue with version 3.3.1, but this problem has been fix in version 3.4.0

 

https://support.smartbear.com/readyapi/docs/general-info/version-history/bugs-fixed-in-ver-3-4.html

 

The java.util.Date class didn't function properly in Groovy scripts since ReadyAPI 3.3.1 (RIA-14157)

 

Simon

cancel
Showing results for 
Search instead for 
Did you mean: