jmeter convert date from EST to UTC

一曲冷凌霜 提交于 2019-12-04 14:53:06

Add groovy-all.jar to jmeter/lib folder

And use JSR223Sampler with Groovy and Compilation Cache key and following code:

import java.text.SimpleDateFormat;
import java.util.TimeZone;
import java.util.Date;

SimpleDateFormat estFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
SimpleDateFormat gmtFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
TimeZone gmtTime = TimeZone.getTimeZone("GMT");
TimeZone estTime = TimeZone.getTimeZone("EST"); 
estFormat.setTimeZone(estTime);
gmtFormat.setTimeZone(gmtTime); 
String endDate = vars.get("endDate");
Date endDateAsDate= estFormat.parse(endDate);
vars.put("dt1", gmtFormat.format(endDateAsDate));

You can then use ${dt1}

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!