1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| public class TimeUtils { public static Timestamp getMonthDay15(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.DAY_OF_MONTH, 15); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); return new Timestamp(calendar.getTimeInMillis()); } }
public class FeeJob implements Job {
private final Log logger = Logger.get(FeeJob.class);
@Override public void execute(JobExecutionContext jec) { Date date = new Date(); if (TimeUtils.getMonthDay15(date).getTime() != date.getTime()) { return; }
long t1 = System.currentTimeMillis(); long spend = System.currentTimeMillis() - t1; logger.info(String.format("%s|执行xxx任务,耗时%s:", getClass().getName(), spend)); } }
|