java - 在 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 脚本中运行它
解决方案
您必须在代码开头添加 import 语句:
import java.text.SimpleDateFormat;
请注意,您最好转而使用 JSR223 组件而不是 Beanshell
推荐阅读
- python - 如何查看数据框组中的元素
- javascript - POSTMAN - EXPRESS - 在写入文件之前修改 JSON
- twitter-bootstrap - vue-clipboard2 在 bootstrap-vue 模态中不起作用
- c# - 无法从下拉列表中选择元素 - 找不到下拉选择器
- c - 如何保护注册表不使用 deleteservice?
- javascript - JavaScript Fetch API:如何将数据存储在外部变量中
- javascript - 通过ajax加载时表单onsubmit不起作用
- ruby-on-rails - 从sitemap.rb中的route.rb获取路径时如何确定任何控制器路径的http方法?
- python - 如何将行分成 10 分钟的间隔?
- java - 如何修复“File.exists()”错误的布尔返回?