Forum Discussion

Svetlana's avatar
Svetlana
Occasional Contributor
9 years ago

Current date in SoapUI NG

Hello,

 

I need to insert the current date into XML file. Is there an opportunity to generate the current date? Data Generator doesn't allow that.

  • try using following code.

    TimeZone.setDefault(TimeZone.getTimeZone('EST'))
    def now = new Date();
    def ExecutionStartDate = now.format("yyyy-MM-dd hh:mm:ss.SSS")

     

    Note that you can change the timezone and date format as you need.

  • You can do it in a Groovy script then set the date to a custom property. You should then easily be able to insert into your XML

  • gurunath's avatar
    gurunath
    New Contributor

    try using following code.

    TimeZone.setDefault(TimeZone.getTimeZone('EST'))
    def now = new Date();
    def ExecutionStartDate = now.format("yyyy-MM-dd hh:mm:ss.SSS")

     

    Note that you can change the timezone and date format as you need.

  • Svetlana's avatar
    Svetlana
    Occasional Contributor

    Gurunath, thank you for you reply!

     

    I have one question to you. Where can I insert that code to be able to use variable ExecutionStartDate in my XML script?

     

    • JustinM89's avatar
      JustinM89
      Contributor

      You can do it in a Groovy script then set the date to a custom property. You should then easily be able to insert into your XML