0

I'm working on API load testing and my current local timezone is IST (India Standard Time) UTC+5:30. The API used for store offline data and android developers are sending record created time in UTC Time. So, API developer asks me to send created time same as android developer sends in UTC time rather than local time.

My question is "How can send UTC Now time or convert local time to UTC timezone?". I don't have any idea to do this.

I tried this solution jmeter convert date from EST to UTC, but it does not work for me.

0

Add JSR223 PreProcessor to generate the UTC timezone based upon your current time before the request

Add the below code to your preprocessor

import java.time.*;
import java.time.format.*;

String localDateTime3  = LocalDateTime.now(ZoneId.of("UTC-05:30")).toString();
println("Date for the UTC time zone: " + localDateTime3);
vars.put('date',localDateTime3);
println(vars.get('date'))

Now you can use ${date} in your request payload to send the date data

Reference: https://www.blazemeter.com/blog/creating-and-testing-dates-in-jmeter-learn-how/

| improve this answer | |
  • Tried this solution but the UTC Time seems to send wrongly as "2020-03-13T22:47:59.788" while developer says actual UTC time is "2020-03-14T04:17:59". – BhavinD. Mar 14 at 4:22
0

You can use __groovy() function to generate the current time in the given time zone like:

${__groovy(new Date().format("yyyy-MM-dd'T'hh:mm:ss"\, TimeZone.getTimeZone('UTC')),)}

Demo:

enter image description here

References:

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.