Timestamp in XML using feeders and ElFileBody

I have a fully working test with values for time stamp hard-coded like this:




Using i.e. SoapUI I could say:


com:publicationTime${=import java.text.SimpleDateFormat ; new SimpleDateFormat(“YYYY-MM-dd’T’HH:mm:ss”).format(new Date(System.currentTimeMillis()))}</com:publicationTime>


and the test runs the function and creates currentTimeMillis() as an actual timestamp.

However with Gatling I have implemented feeders and a parameter in the XML and ElFileBody, but this does not convert to currentTimeMillis obviously.

How can I implement currentTimeMillis realtiume/runtime given the setup of a scenario?

You can store an object in the session that has a toString method that generates a timestamp.

object ISO_Timestamp {
override def toString = new SimpleDateFormat(“YYYY-MM-dd’T’HH:mm:ssZ”).format(new Date())

Now store that in the session:

exec( _.set( “ISO_TIMESTAMP”, ISO_Timestamp ) )

And when you need a timestamp as an ISO date/time string, you reference the object in an expression, like so:


There may be some other fun and fancy things you can accomplish if you set your mind to it, but that solves your initial query.