public static long getDays(String date1, String date2) {
        if (date1 == null || date1.equals(""))
            return 0;
        if (date2 == null || date2.equals(""))
            return 0;
        // 转换为标准时间
        SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
        Date date = null;
        Date mydate = null;
        try {
            date = myFormatter.parse(date1);
            mydate = myFormatter.parse(date2);
        } catch (Exception e) {
        }
        long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
        return day;
    }
public static long getDays ( String date1 , String date2 ) { if ( date1 == null || date1 . equals ( "" ) ) return 0 ; if ( date2 == null || date2 . equals ( "" ) ) return 0 ; SimpleDateFormat myFormatter = new SimpleDateFormat ( "yyyy-MM-dd" ) ; Date date = null ; Date mydate = null ; try { date = myFormatter . parse ( date1 ) ; mydate = myFormatter . parse ( date2 ) ; } catch ( Exception e ) { } long day = ( date . getTime ( ) - mydate . getTime ( ) ) / ( 24 * 60 * 60 * 1000 ) ; return day ; }
两个时间之间的天数

@param date1
@param date2
@return