Forum Discussion

Sandyapitester's avatar
Sandyapitester
Frequent Contributor
8 years ago

SOAPUI PRO : Rest API request parameter need to pass current date and time format value

Hi All, SOAPUI PRO - Rest API request parameter need to pass current date and time in my request parameter value Like : { "Profile": "Group", "family": [ { "name": "Remo", "age": 24 }], "currentDateandtime": "2013-01-08 11:25:00.0000000 +05:30" } Need to Pass current date and time in "currentDateandtime" parameter Please share your valuable suggestion
  • nmrao's avatar
    nmrao
    8 years ago

    You can just use:

    ${= new Date().format('yyyy-MM-dd HH:mm:ss.SSSSS Z')}
  • groovyguy's avatar
    groovyguy
    Community Hero

    What I typically use for needing the exact NOW timestamp in a request (this works for SOAP requests, not sure about REST) is to utilize inline property scripts, as seen below. This will process the exact timestamp of when the request is processed/sent every time. 

     

    ${= Calendar.getInstance(TimeZone.getTimeZone('GMT')).format("yyyy-MM-dd'T'HH:mm:ss") }
  • Sandyapitester's avatar
    Sandyapitester
    Frequent Contributor
    Hi All, I have used the below script ${=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSSS XXX‌").format(new Date())} Which am getting the date format value with ?? like "2017-05-22 22:03:38.0000270 +05:30??" istead of "2017-05-22 22:03:38.0000270 +05:30" Why am getting this question mark?
    • nmrao's avatar
      nmrao
      Champion Level 3

      You can just use:

      ${= new Date().format('yyyy-MM-dd HH:mm:ss.SSSSS Z')}