Forum Discussion

andi1377's avatar
14 years ago

Substring from a property transfer

hi,
I am a newbie with soapui. I am testing some services with the free-version of the soapui.
In my test, I fetch a datetime from our database in the following format: 2011-04-14 12:00:00
The datetime I have to use in the following requests.
But the request expect the datetime in the following format 2011-04-14T12:00:00

So, my idea was, to store the first part (date) in one property transfer, and the time in the second property transfer.
After this, I can build the request with the 3 elements date+T+time.

Could someone explain me in detail, how I can do this?

2 Replies

  • SiKing's avatar
    SiKing
    Community Expert
    Personally, I find this sort of thing easiest as a Groovy step. Google something like "Java manipulate date" and go from there.
  • Finan's avatar
    Finan
    Frequent Contributor
    You could achieve it via the following groovy script:
    dateString = new Date().format("yyyy-MM-dd HH:mm:ss");
    dateInstance = new Date().parse("yyyy-MM-dd HH:mm:ss", dateString);
    newDateString = dateInstance.format("yyyy-MM-dd'T'HH:mm:ss");


    dateString is to simulate your db data String.
    you could change this to the following for your case:
    dateString = context.expand( '${jdbc_response#ResponseAsXml#//Results[1]/DateString[1]}' )
    dateInstance = new Date().parse("yyyy-MM-dd HH:mm:ss", dateString);
    newDateString = dateInstance.format("yyyy-MM-dd'T'HH:mm:ss");