Java to determine whether the number of hours over such as: 24

 

 

 / ** determined whether the number of hours, such as more than: 24 
     * 
     * @param tableTime traffic time 
     * @param hour how many hours 
     * @return Boolean 
     * @throws Exception
      * / 
    public  static  Boolean judgmentDate (tableTime String, Integer hour) throws Exception { 
        String currentTime DateUtil.getCurrentTime = ( "the mM-dd-YYYY HH: mm: SS"); // this time 

        the SimpleDateFormat SDF = new new the SimpleDateFormat ( "Md-YYYY HH: mm: SS" ); 

        a Date Start = sdf.parse (tableTime) ;

        Date end = sdf.parse(currentTime);

        long cha = end.getTime() - start.getTime();

        if (cha < 0) {

            return false;
        }

        double result = cha * 1.0 / (1000 * 60 * 60);

        if (result <= hour) {

            return true;//是小于等于 hour 小时

        } else {

            return false;

        }

    }

 

Guess you like

Origin www.cnblogs.com/w-yu-chen/p/12565771.html