jmeter日期处理beanshell(2)
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.text.ParseException;
public static String getDate(int days){
String startDate = "";
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(5, days);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
startDate = sdf.format(cal.getTime());
System.out.print(sdf.format(cal.getTime()));
vars.put("startDate",startDate);
return startDate;
}
getDate(0);
0代表获取当天