固定时间加上日,星期,或者月份
作者:互联网
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();
}
标签:星期,performratetime,加上,ca,performtime,固定,Date,Calendar,str1 来源: https://www.cnblogs.com/2048tw/p/14784110.html