• 判断某时间是否处于时间区域内


    /**
    * @param nowDate   要比较的时间
    * @param startDate 开始时间
    * @param endDate   结束时间
    * @return   Y 在时间段内,N不在时间段内
    * @throws Exception
    */
    public static String panduanTimeSection(String nowDate, String startDate, String endDate) throws Exception{
       SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
       try{
          Date now =  format.parse(nowDate);
          Date start = format.parse(startDate);
          Date end = format.parse(endDate);
          //使用Date的方法转为毫秒比较大小
          if(now.getTime() >= start.getTime()){
          //当前时间大于等于开始时间
          if(now.getTime() <= end.getTime()){
          //当前时间小于等于结束时间
          return "Y";
          }else {
             return "N";
          }
          }else {
            return "N";
          }
          }
          catch (Exception e){
              System.out.println(e.getMessage());
              return "N";
            }
        }
    往事如烟,余生有我.
  • 相关阅读:
    团队冲刺第十天
    每日学习
    每日学习
    团队冲刺第九天
    每日学习
    2021.4.26
    2021.4.23
    2021.4.22
    2021.4.21
    2021.4.20
  • 原文地址:https://www.cnblogs.com/assistants/p/9887864.html
Copyright © 2020-2023  润新知