JMeter 生成精度度为分钟的时间戳文件名
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import java.text.SimpleDateFormat;
props.put("fileNameSign","");
String fmt = "yyyyMMddHHmm";
SimpleDateFormat formatter = new SimpleDateFormat(fmt);
Calendar cal=Calendar.getInstance();
Date now=new Date();
cal.setTime(now);
//获取当前时区的时间戳
vars.put("FileCurrentTime",formatter.format(cal.getTime()));
// 获取utc格式的时间戳
//formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
props.put("fileNameSign",formatter.format(cal.getTime()));
用If controller控制是否需要生成新的文件名:
"${FileNameSign}" != "${__time(YMD,)}${__time(HHmm,)}"