• 时间戳的实际使用


    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();
      
     }*/
    }
  • 相关阅读:
    css定位
    css遗漏
    php字符操作
    php类于对象
    php数组的操作
    php基础
    javascript显式类型的转换
    【模板】并查集
    图论三种做法:朴素版Dijkstra、堆优化(优先队列)Dijkstra、spfa(队列优化版Bellman-Ford)
    二分之一网打尽
  • 原文地址:https://www.cnblogs.com/sukuokuo/p/9648027.html
Copyright © 2020-2023  润新知