• 时间戳的实际使用


    package com.asiainfo.openapi.component;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Lazy;
    import org.springframework.scheduling.annotation.EnableScheduling;
    import org.springframework.scheduling.annotation.Scheduled;
    import org.springframework.stereotype.Component;
    import com.asiainfo.openapi.service.ISyncMetaInfoService;
    @EnableScheduling
    @Component
    @Lazy(false)
    public class ScheduledQuartz {
     
     @Autowired
     private ISyncMetaInfoService syncService;
     
    // @Scheduled(cron= "0 0/1 15,* * * ?")
    // public void test() {
    //        System.out.println("测试每分钟执行一次:" + new Date()); 
    //    }
     
     //0 0 1 ? * L 每周星期天凌晨1点实行一次;0 44 22 ? * SAT 每个周六的22:44执行
     //0 0/2 * * * ? 每隔2分钟
    //  "0 15 10 ? * MON-FRI" 周一至周五的上午10:15触发 
     @Scheduled(cron= "0 44 22 ? * SAT")
    // @Scheduled(cron= "0 */5 * * * ?")
     public void run() throws ParseException {
      long createTimes = System.currentTimeMillis() - 7*24*60*60*1000;
      long createTime = createTimes/1000;
      syncService.syncIncMetaDataByTime(createTime);
            System.out.println("时间戳" + createTime);
           
            System.out.println("当前时间" + new Date());
            System.out.println("执行时间" + new Date(createTimes)); 
           
        }
     /*public static void main(String[] args) throws ParseException {
      ScheduledQuartz scheduledQuartz = new ScheduledQuartz();
      scheduledQuartz.run();
      
     }*/
    }
  • 相关阅读:
    Linux下如何从mysql数据库里导出导入数据
    安装好Pycharm后如何配置Python解释器简易教程
    Windows离线安装Python第三方库的方法
    时间输入框的测试方法
    doc转html
    pdf转png图片
    html转pdf
    html转pdf
    复习 注解反射
    Mybatis实现插入数据的时候将主键赋值给对象的两种方法
  • 原文地址:https://www.cnblogs.com/sukuokuo/p/9648027.html
Copyright © 2020-2023  润新知