判断两个日期之间的长度

/**

*结束日期与开始日期之间的间隔天数

*return 两个日期之间的天数

*/

private Long dateTest(String startDate, String endDate) throws ParseException {
        Date start = new Date();
        Date end  = new Date();
        if(startDate.contains("-")){
            start =  Toolbox.parseDate(startDate, "yyyy-MM-dd");
        }else{
            start = Toolbox.parseDate(startDate, "yyyyMMdd");
        }
        if(endDate.contains("-")){
            end = Toolbox.parseDate(endDate, "yyyy-MM-dd");
        }else{
            end = Toolbox.parseDate(endDate, "yyyyMMdd");
        }
        long day = (end.getTime() - start.getTime()) / (24 * 60 * 60 * 1000);
        return day;
    }

原文地址:https://www.cnblogs.com/lius1/p/5892741.html