Mohd Sarfraz
Mohd Sarfraz

Reputation: 21

How to write beanshell program ? beanshell is a editor but i dont know how to use it and where?

I have no knowledge of beanshell. Please tell me how to write a beanshell program.

Beanshell is an editor but I don't know how to use it and where? Beanshell is powerful editor which is being used in script please let me know in detail how can we use java defined variable or Classes.

Upvotes: 1

Views: 663

Answers (1)

jgabb
jgabb

Reputation: 554

Here is a simple example. You code is just like java. If you want a function, add a function and do a function call.

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

Date now = new Date(); // get current time
SimpleDateFormat sdf = new SimpleDateFormat("MMM dd yyyy HH:mm:ss.SSS");     
String mydate = sdf.format(now);// format date as string
long epoch = now.getTime();
String s = String.valueOf(epoch);
vars.put("mydate",s); // save date to JMeter variable named "mydate"

Upvotes: 2

Related Questions