zoukankan      html  css  js  c++  java
  • Jmeter-获取当天00:00的时间戳

    //【1】当前凌晨时间戳

    long
    nowTime =System.currentTimeMillis(); long todayStartTime =nowTime - ((nowTime + TimeZone.getDefault().getRawOffset()) % (24 * 60 * 60 * 1000L)); vars.put("beginTime",String.valueOf(todayStartTime));

    
    
    //【2】当前凌晨时间戳
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.text.*;
        //当天日期
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String today = simpleDateFormat.format(date.getTime());
    
        //1、当天凌晨(毫秒)
        long daytime1 = simpleDateFormat.parse(today).getTime();
        vars.put("beginTime",String.valueOf(daytime1));

     

    
    
    //【3】当前凌晨时间戳

    long
    now = System.currentTimeMillis() / 1000l; long daySecond = 60 * 60 * 24; long dayTime4 = (now - (now + 8 * 3600) % daySecond) * 1000; vars.put("beginTime",String.valueOf(dayTime4));

    //【4】当前凌晨时间戳

    Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); long daytime3 = c.getTimeInMillis(); vars.put("beginTime",String.valueOf(daytime3));

      //获取当天23:59:59
      Calendar c = Calendar.getInstance();
      c.set(Calendar.HOUR_OF_DAY, 23);
      c.set(Calendar.MINUTE, 59);
      c.set(Calendar.SECOND, 59);
      c.set(Calendar.MILLISECOND, 0);
      long daytime31 = c.getTimeInMillis();
      vars.put("endTime",String.valueOf(daytime31));

     

  • 相关阅读:
    MYBATIS 的parameter
    深入了解MyBatis参数
    js之onload事件的一点使用心得
    js中document.write的那点事
    MyBatis直接执行SQL查询及批量插入数据
    ng 服务
    ng json格式的序列化和反序列化
    ng 自定义过滤器的创建和使用
    ng 过滤器
    ng 双向数据绑定 实现 注册协议效果
  • 原文地址:https://www.cnblogs.com/Face-All/p/15161742.html
Copyright © 2011-2022 走看看