固定时间加上日,星期,或者月份
Posted 陌离莫离
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了固定时间加上日,星期,或者月份相关的知识,希望对你有一定的参考价值。
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();
}
以上是关于固定时间加上日,星期,或者月份的主要内容,如果未能解决你的问题,请参考以下文章