Unanswered question

use of java.time.Instant in javascript

How might I convert this beanshell preprocessor script in jmeter to neoload javascript?

import java.time.Instant;
String epoc = Long.toString(Instant.now().toEpochMilli());
vars.put("sequence", epoc);

In neoload I will use,
context.variableManager.setValue("sequenceNumber",epoc);

but I get error on the use of import statement.

rob J.
rob J.

rob J.

Level
0
3 / 100
points

Answers

rob J.
rob J.

rob J.

Level
0
22 / 100
points

Still have issue, but this is perhaps just a general question of how do use standard java classes like java.time in a neoload script?

rob J.
rob J.

rob J.

Level
0
22 / 100
points

Since java.time.Instant is within Java SE not some custom class (https://docs.oracle.com/javase/8/docs/api/java/time/Insta...) , how can I add just that?

I only dabble with java, but your class imports the Java SE java.time.instant class, when you create a jar I would assume all the dependancies would also be in the jar? then you can just delare your method in the java script.

Not directly related to your question but it seems that your goal is to get the current time in milliseconds. Why don't you use the NeoLoad "current date" variable and choose the milliseconds format from the drop down list?