当前位置:网站首页>BeanShell脚本获取当前时间
BeanShell脚本获取当前时间
2022-07-17 00:15:00 【[email protected]】
获取10位时间戳:${__time(,)}
1、__time:获取时间戳、格式化时间
(1)、${__time(yyyy-MM-dd HH:mm:ss:SSS,time)} :格式化生成时间格式 2022-05-16 11:56:23:635
(2)、${__time(,)}:默认该公式精确到毫秒级别, 13位数 182794855253
(3)、${__time(/1000,)}:该公式精确到秒级别, 10位数 1827835371
(4)、${__time(yyyy-MM-dd,)}:该公式格式化生成的时间为:2022-04-16
(5)、${__time(yyMMdd,)}:该公式格式化生成的时间为:161036
获取当前时间的脚本:import java.util.*; import java.text.SimpleDateFormat; String str1 = (new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")).format(new Date()); vars.put("sta",str1);
展开
可以引用sta来获取当前时间
当前日期加1的脚本
import java.util.*;
import java.text.SimpleDateFormat;
String str1 = (new SimpleDateFormat("yyyy-MM-dd")).format(new Date()); //当前日期
String str2 = (new SimpleDateFormat("yyyy-MM-dd")).format(DateUtil.getDayAfter(new Date())); // 当前日期+1
String str3 = (new SimpleDateFormat("hh:mm:ss")).format(new Date());
String str4 = DateUtil.getDateFormat(DateUtil.getDateFormat("2017-11-21")); //指定日期
String str5 = (new SimpleDateFormat("yyyy-MM-dd")).format(DateUtil.getDayAfter(DateUtil.getDateFormat("2017-11-21"))); // 当前日期+1
vars.put("sta",str1);
vars.put("sta1",str2);
vars.put("sta2",str4);
vars.put("sta3",str5);
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
Date date =new Date(); //获取当前时间
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String nowDate = sf.format(date);
vars.put("startTime",nowDate);
//System.out.println(nowDate);
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR,+5); //当前时间+5天
String senderDate = sf.format(cal.getTime());
vars.put("endTime",senderDate);
// 时间戳:当前时间往后移位3天
// var now_date = new Date().getTime()/1000;
var now_date = new Date().getTime()/1000+259200;
vars.put("now_date",now_date.toString());
// 时间戳:当前时间戳10位
var now_date = new Date().getTime()/1000;
vars.put("timestamp",now_date.toString());
// 时间戳:当前时间戳13位
var now_date = new Date().getTime();
vars.put("timestamp1",now_date.toString());
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_60664821/article/details/123356591
边栏推荐
- Engineering compilation: makefile and cmake (I)
- JS note 1
- 二叉树的遍历
- Logic vulnerability - login verification code security
- Difference between close and shutdown
- Analysis of the paradise of metauniverse developers the ecological value of the metauniverse protocol caduceus
- Bugku problem solution
- 【工具篇】Unity2D人物控制器,控制2D玩家移动跳跃,四方向和水平方向
- Attack and defense world - easytornado notes
- Visual Studio 2019-QT调试
猜你喜欢

Line process of pool components

树和堆知识点总结

Gdb+vscode for debugging 2 - GDB breakpoint related

【解决方案】win11中本地组策略编辑器(gpedit.msc)打不开

bugku---game1

Signal and system experiment

ENVI_ Idl: read the text file and output it in GeoTIFF format + simple mean interpolation

bugku----正则匹配,cookies

逆元(名字太多人用我就加这几个字)

STL--stack容器
随机推荐
测试知识准备
ENVI_ Idl: reading of text files (mainly txt and CSV files)
[unity panel attribute literacy] set texture import settings after importing textures
STL -- set container
[tools] unity screen drawing line, unity screen drawing Hsj drawing tool
信号与系统实验
next数组-循环节
30分钟搞懂 HTTP 缓存
ENVI_ Idl: batch splice the daily data of MODIS swath and output it in GeoTIFF format
树和堆知识点总结
Memory pooling of pooled components
Installing MySQL and JDBC on Windows
最短路/次短路/K短路
ENVI_ Idl: average calculation + analysis of MODIS swath products in batches
Stl--queue container
简单记录一下并查集
Leetcode 198:House Robber
【Unity编辑器扩展】Unity内部Asset资源配置ScriptableObject
STL -- map container
【Unity编辑器扩展】显示资源目录下所有文件所占内存大小