码迷,mamicode.com
首页 > 其他好文 > 详细

判断现在时间时间在不在两个时间段之间

时间:2020-01-07 16:39:22      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:als   star   现在   exce   art   cal   ret   现在时间   turn   

 1  /**
 2      * 判断现在时间时间在两个时间段之间
 3      *
 4      * @param nowTime1 现在时间
 5      * @param startTime1 开始时间
 6      * @param endTime1 结束时间
 7      * @return
 8      * @throws ParseException
 9      */
10     public static boolean isEffectiveDate(String nowTime1, String startTime1, String endTime1) throws ParseException {
11         String format = "HH:mm:ss";
12         Date nowTime = new SimpleDateFormat(format).parse(nowTime1);
13         Date startTime = new SimpleDateFormat(format).parse(startTime1);
14         Date endTime = new SimpleDateFormat(format).parse(endTime1);
15         Calendar date = Calendar.getInstance();
16         date.setTime(nowTime);
17         Calendar begin = Calendar.getInstance();
18         begin.setTime(startTime);
19         Calendar end = Calendar.getInstance();
20         end.setTime(endTime);
21         if (date.after(begin) && date.before(end)) {
22             return true;
23         } else {
24             return false;
25         }
26     }

判断现在时间时间在不在两个时间段之间

标签:als   star   现在   exce   art   cal   ret   现在时间   turn   

原文地址:https://www.cnblogs.com/mzc--/p/12161823.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!