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

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();
}
上一篇:根据当前日期自增一个月


下一篇:Java Calendar类实现日期的操作