Jmeter beanshell将13位的时间戳转化为年月日的字符串
import java.text.SimpleDateFormat;
import java.util.Date;
public static class DateUtil {
public static String stampToDate(String s){
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm”);
long lt = new Long(s);
Date date = new Date(lt);
res = simpleDateFormat.format(date);
return res;
}
}
String startTime = vars.get(“createTime”);
String date = DateUtil.stampToDate(startTime);
vars.put(“createTime”,date);
log.info(date);