/** * 返回二个时间相差的分分钟数,如果一个为空,返回为0; * @param startDate,比如08:09 * @param endDate,如18:09 * @return */ public static int getMinutesDiff(String startDate,String endDate){ int ret=0; if(RStringUtils.isEmpty(startDate) || RStringUtils.isEmpty(endDate)){ // return ret; }else{ String startDateStr[]=startDate.split(":"); String endDateStr[]=endDate.split(":"); if(startDateStr[0].startsWith("0")){ startDateStr[0]=startDateStr[0].substring(1); } if(startDateStr[1].startsWith("0")){ startDateStr[1]=startDateStr[1].substring(1); } if(endDateStr[0].startsWith("0")){ endDateStr[0]=endDateStr[0].substring(1); } if(endDateStr[1].startsWith("0")){ endDateStr[1]=endDateStr[1].substring(1); } int s=Integer.parseInt(startDateStr[0])*60+Integer.parseInt(startDateStr[1]); int e=Integer.parseInt(endDateStr[0])*60+Integer.parseInt(endDateStr[1]); ret=e-s; } return ret; }
取消
评论