public String getSpendTime(TechScheduleServiceBean bean) { TechScheduleBean bean2 = bean.getBean(); long beginTime = bean2.getBegin_time().getTime(); long endTime = bean2.getEnd_time().getTime(); double days = (endTime-beginTime) / (1000 * 60 * 60 * 24); double hours = ((endTime-beginTime) - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60); double minutes = ((endTime-beginTime) - days * (1000 * 60 * 60 * 24) - hours * (1000 * 60 * 60)) / (1000 * 60); double minute = minutes / 60; double spendtime = hours + minute; DecimalFormat df = new DecimalFormat("#.##"); return df.format(spendtime); }