@Scheduled(cron ="0 35 16 * * ?")
public void testScheduled(){
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM");
try {
// 起始日期
Date d1 = sdf.parse("2019-02");
// 结束日期
Date d2 = sdf.parse("2020-04");
Date tmp = d1;
Calendar dd = Calendar.getInstance();
dd.setTime(d1);
while (tmp.getTime() < d2.getTime()) {
tmp = dd.getTime();
System.out.println(sdf.format(tmp));
adMonthlyDataService.syncConsumeCptMonth(sdf.format(tmp));
dd.add(Calendar.MONTH, 1);
}
}catch (ParseException e) {
e.printStackTrace();
}
}






网友评论