Forum Discussion

mgroen2's avatar
mgroen2
Super Contributor
6 years ago

get current date and time and put it in the body of a request (json)

I need to send a request populated with current date and time in the body as Json.

In this format:

"DatumtijdOndertekening": "${__time(yyyy-MM-dd'T'hh:mm:ssX)}"

What do I need to get this working?

 

Thanks,
Mathijs

 

  • If you are using jdk 8, below should work.

     

    You almost there, its trivial.

    {
       "DatumtijdOndertekening" : "${= java.time.OffsetDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ssZ'))}"
    }

     

  • nmrao's avatar
    nmrao
    Champion Level 3

    If you are using jdk 8, below should work.

     

    You almost there, its trivial.

    {
       "DatumtijdOndertekening" : "${= java.time.OffsetDateTime.now().format(java.time.format.DateTimeFormatter.ofPattern('yyyy-MM-dd\'T\'HH:mm:ssZ'))}"
    }

     

    • mgroen2's avatar
      mgroen2
      Super Contributor

      Hi nmrao ,

       

      thanks a lot for your reaction. It worked!

       

      Strange thing is, I don't have any Java installed on the machine (Windows-> Control Panel-> Programs and Features doesnt display any Java client installed).

      You have an explanation?

       

      • nmrao's avatar
        nmrao
        Champion Level 3
        mgroen2,
        Nice to know that it worked. Can this be closed then?

        Though you don't install java, JRE gets shipped along with SoapUI installation.