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");//把当前时间转成yyyy形式
String nowDate = sf.format(date);//得到当前时间的yyyy-mm-dd形式
log.info("------nowDate------"+ nowDate);
String endTimeNowDate = nowDate+" 23:59:59";
log.info("+++++++拼接后的结束时间++++++++endTimeNowDate:"+ endTimeNowDate);
vars.put("endTimeNowDate",endTimeNowDate);
Calendar cal = Calendar.getInstance();
cal.setTime(sf.parse(nowDate));
long nowDate1 = cal.getTimeInMillis();
vars.put("nowDate1",nowDate1.toString());
//当前时间,把nowDate1放在结束时间;
cal.add(Calendar.DAY_OF_YEAR,+1); //当前时间+1天
String orderDate = sf.format(cal.getTime());
sfDate = sf.parse(orderDate);
cal.setTime(sfDate);
long nowDate2 = cal.getTimeInMillis();
vars.put("nowDate2",nowDate2.toString());
/*******************************************************/
cal.add(Calendar.DAY_OF_YEAR,-8); //当前时间-8天
String senderDate = sf.format(cal.getTime());
log.info(">>>>>>>>>>>>>>>>>>>>+senderDate:"+ senderDate);
String startTimeSenderDate= senderDate+" 00:00:00" ;
log.info(">>>>>>>>>>>拼接后的开始时间>>>>>>>>>+startTimeSenderDate:"+ startTimeSenderDate);
vars.put("startTimeSenderDate",startTimeSenderDate);
/*******************************************************/
sfDate1 = sf.parse(senderDate);
cal.setTime(sfDate1);
long endDate = cal.getTimeInMillis();
vars.put("endDate",endDate.toString());
//当前时间-6天 ,把endDate,放在开始时间
}
catch(Exception e){
log.info("抛出异常");
}