jmeter - How to change the date format of the correlated date? -
i'm capturing date in 1 request can send captured date parameter next request. in next request date should sent different format. in order send date need modify date format how can that?
for example, if have ${date}
variable value of 27/01/16
, need convert january 27, 2016
- add beanshell preprocessor child of 2nd request
put following code preprocessor's "script" area:
import java.text.simpledateformat; simpledateformat source = new simpledateformat("dd/mm/yy"); simpledateformat target = new simpledateformat("mmmm dd, yyyy"); date date = source.parse(vars.get("date")); string newdate = target.format(date); vars.put("date", newdate);
after above code execution
${date}
variable hold new value date in different format
see:
- simpledateformat class javadoc patterns explained
- how use beanshell: jmeter's favorite built-in component information on beanshell scripting in jmeter
Comments
Post a Comment