根据已知时间计算时间差

    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);
    }

 

posted @ 2017-02-27 20:16  滴滴滴滴哒  阅读(401)  评论(0编辑  收藏  举报