Forum Discussion

RESEARCH_IN_MOT_1's avatar
RESEARCH_IN_MOT_1
New Contributor
14 years ago

Scipt in MockService

All

I am having trouble generating a script for a mockservice. I just want to return a value of the current date to the calling service but everything I have tried hasn't worked.

def today = new Date()
or
context today = new Date()

I looked at the documentation and it doesn't really explain it that well.

4 Replies

  • Hi,

    do you want to include as part of a response message? Easiest in that case is to just inline ${=new java.util.Date().toString()} in your response XML..

    does that help?

    regards!

    /Ole
    SmartBear Software
  • Hi,

    you can write multiline scripts inside the ${=....} constructs so you could set up a SimpleDateFormat to format the date as desired. Alternatively you could assign the date to a context property in the response script:

    context.formattedDate = ...

    and then use that property in the response xml with

    ${formattedDate}

    Hope this helps!

    /Ole
    SmartBear Software