1 /** 2 * 组织时间差 3 * @tags @return 4 * @exception 5 * @author wanghc 6 * @date 2015-7-22 下午6:49:26 7 * @return String 8 */ 9 private String setDateDifferenceStr(Date startTime,Date endTime){ 10 StringBuffer sb = new StringBuffer(); 11 if(ParamValidator.validatorParamsIsEmpty(startTime,endTime)){ 12 sb.append("00:00:00"); 13 return sb.toString(); 14 } 15 Long l = endTime.getTime() - startTime.getTime(); 16 long ss=l/(1000); //共计秒数 17 int MM = (int)ss/60; //共计分钟数 18 int hh=(int)ss/3600; //共计小时数 19 //int dd=(int)hh/24; //共计天数 20 if((hh%24) >=0 && (hh%24) < 10){ 21 sb.append("0"+(hh%24)); 22 }else{
sb.append(hh%24);
} 23 if((MM%60) >=0 && (MM%60) < 10){ 24 sb.append(":0"+(MM%60)); 25 }else{
sb.append(":"+(MM%60));
} 26 if((ss%60) >=0 && (ss%60) < 10){ 27 sb.append(":0"+(ss%60)); 28 }else{ 29 sb.append(":"+(ss%60)); 30 } 31 return sb.toString(); 32 }