Jmeter如何打印时间戳

2024-10-13 00:06:40

1、Jmeter中提供了一种函数,可以打印时间戳,如下图

Jmeter如何打印时间戳

3、执行,查看结果树,可以看到结果中,将当前时间打印出来了哦~

Jmeter如何打印时间戳Jmeter如何打印时间戳

6、附:beanshell打印时间的代码import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;try{Date date =new Date(); //获取当前时间SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String nowDate = sf.format(date);Calendar cal = Calendar.getInstance();cal.setTime(sf.parse(nowDate));cal.add(Calendar.DAY_OF_YEAR,+0);String orderDate = sf.format(cal.getTime());cal.add(Calendar.DAY_OF_YEAR,+365);String senderDate = sf.format(cal.getTime());vars.put("orderDate",orderDate);vars.put("senderDate",senderDate);}catch(Exception e){}

Jmeter如何打印时间戳
猜你喜欢