How to perform operations in JMeter with Functions of time

The last for today.
I wanna make a summ of two Functions in JMeter, like:

${__javaScript((new Date()).toISOString())} + ${__Random(1000,1500)}

Probably, the STRING is breaking the JMeter execution. This should be a POST method to save in the database something like: 2024-02-08 17:16:58.130

But I wanna take the actual time (with the format shown) and summ random number between 1000~1500ms. There is a way to perform this?

enter image description here

enter image description here

  1. StartDateTime: you can use just __time() function like:

    ${__time(yyyy-MM-dd hh:mm:ss.SSS,)}
    
  2. EndDateTime: you will need to go for __groovy() function like:

    ${__groovy(new Date(System.currentTimeMillis() + org.apache.commons.lang3.RandomUtils.nextInt(1000\,1500)).format('yyyy-MM-dd hh:mm:ss.SSS'),)}
    

Leave a Comment