固定时间加上日,星期,或者月份

Date performtime = (Date) map.get("performtime") == null ? null : (Date) map.get("performtime");
//如果下一次执行时间大于当时时间,则跳出,不执行
Date now = new Date();
if (performtime != null && performtime.after(now)) {
continue;
}
String performratetime=map.get("performratetime").toString();
if (performratetime.contains("日")){
String str1=performratetime.substring(0, performratetime.indexOf(","));
int a = Integer.parseInt(str1);
Calendar ca = Calendar.getInstance();
ca.setTime(performtime);
ca.add(Calendar.DATE, a);
performtime = ca.getTime();
} if (performratetime.contains("周")){
String str1=performratetime.substring(0, performratetime.indexOf(","));
int a = Integer.parseInt(str1)*7;
Calendar ca = Calendar.getInstance();
ca.setTime(performtime);
ca.add(Calendar.DATE, a);
performtime = ca.getTime();
} if (performratetime.contains("月")){
String str1=performratetime.substring(0, performratetime.indexOf(","));
int a = Integer.parseInt(str1);
Calendar ca = Calendar.getInstance();
ca.setTime(performtime);
ca.add(Calendar.MONTH, a);
performtime = ca.getTime();
}

posted on 2021-05-19 10:43  陌离莫离  阅读(69)  评论(0编辑  收藏  举报

导航