首页 > 其他 > 详细

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

时间:2021-05-19 12:55:05      阅读:32      评论:0      收藏:0      [点我收藏+]
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();
}

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

原文:https://www.cnblogs.com/2048tw/p/14784110.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!