获取日期与时间戳小笔记

exec(session =>){

val time = System.currentTimeMillis()

System.out.println("时间戳:" + time)

val dateFormatime : SimpleDateFormat = new SimpleDateFormai("yyyyMMddHHmmss")  //日期显示格式

val date = new Date()  //获取日期时间

val date1 = dateFormatime.format(date)  //限制日期时间格式

System.out.println("日期:" + date1)

session

  .set("time",time)

  .set("date1",date1)

}

在脚本中进行调用:

${date1} ,引号里面的

java中获取时间戳有以下三种方法:

(都是获取的13位时间戳)

public static void main(String[] args) {
  // TODO Auto-generated method stub


  long t1 = System.currentTimeMillis();
  long t2 = new Date().getTime();
  long t3 = Calendar.getInstance().getTimeInMillis();


  System.out.println(t1);
  System.out.println(t2);
  System.out.println(t3);
 }

原文地址:https://www.cnblogs.com/hsyfighting/p/10825617.html