当前位置:网站首页>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
边栏推荐
- flask模板注入
- [unity Editor Extension] the pre-processing and post-processing pictures of unity assets are automatically transferred to sprite2d
- 最短路/次短路/K短路
- 项目性能优化实战:解决首页白屏问题,自定义 loading 动画优化首屏效果
- 西加加
- [tools] unity screen drawing line, unity screen drawing Hsj drawing tool
- STL--stack容器
- Unity笔记1
- 树和堆知识点总结
- STL -- set container
猜你喜欢

Attack and defense world - easytornado notes

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

【Unity开发小技巧】Unity混音器Mixer控制全局音量
![[unity panel attribute literacy] set texture import settings after importing textures](/img/c6/4a50bb848560e1e5c72e714d367109.png)
[unity panel attribute literacy] set texture import settings after importing textures

Buaaos-lab0 experimental report

【Unity编辑器扩展】查找场景和资源内挂载某脚本的所有对象

STL--list容器(链表)

BladeX——精心设计的微服务架构

【Unity面板属性扫盲】导入纹理后设置Texture Import Settings

Chapter 2 - system control principle - > classical control theory
随机推荐
Cookie和Session的区别
Bugku---- regular matching, cookies
How to configure multiple SSH keys for novices (easy to understand hand-in-hand teaching)
Summary of tree and heap knowledge points
并发虚拟用户、RPS、TPS的解读
【Unity开发小技巧】Unity混音器Mixer控制全局音量
静态路由(详)
[hdrp HD rendering pipeline] create hdrp project and upgrade the built-in pipeline project to hdrp project
Leetcode 198:House Robber
网络一般知识(详)
信号与系统实验
【Unity编辑器扩展】Unity内部Asset资源配置ScriptableObject
ENVI_ Idl: batch splice the daily data of MODIS swath and output it in GeoTIFF format
Install websocketpp
ENVI_ Idl: read the text file and output it in GeoTIFF format + simple mean interpolation
sqlmap的使用
Line process of pool components
Analysis of the paradise of metauniverse developers the ecological value of the metauniverse protocol caduceus
【工具篇】Unity快速上手制作2D和2.5D游戏的神器TileMap
Software testing technology interim testing summary | software testing foundation & Executive testing & test design and development