首页 > 解决方案 > 在 Beanshell 中获取 RFC1123_time(使用 JMeter)

问题描述

接口需要在标头中设置 RFC1123 时间我不能在 beanshell 中使用 JMeter

我知道代码在java中工作:

SimpleDateFormat sdf3 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z",Locale.US);
sdf3.setTimeZone(TimeZone.getTimeZone("GMT"));
String rfc1123_3 = sdf3.format(new Date());

但我无法在 Beanshell 脚本中运行它

标签: javajmeterbeanshelljsr223rfc1123

解决方案


您必须在代码开头添加 import 语句:

import java.text.SimpleDateFormat;

请注意,您最好转而使用 JSR223 组件而不是 Beanshell


推荐阅读