我怎样才能得到两个日期之间的天数?

How can i get days between two dates?

如何从两个日期中获取天数,其中一个日期来自数据库,我可以正确检索它,但如何将它与当前系统日期进行比较?我可以使用 settimestamp 函数将当前日期存储到数据库中,但不能将其用于比较我使用过 jodatime,但无法通过

     // TODO add your handling code here:
       JOptionPane.showMessageDialog(null,"Fine test");
        try{
            conn = Connect.ConnectDB();  
            String qw="select bookid,date from borrow";
            //String date1="Select Cast ((JulianDay(ToDate) - JulianDay(FromDate)) As Integer)";
        pst = conn.prepareStatement(qw);
 rs=pst.executeQuery();
 while(rs.next())
 {
     String fine=rs.getString("date");
     //String today=Timestamp(System.currentTimeMillis()
     //String date1="Select Cast ((JulianDay() - JulianDay(fine)) As Integer)";
    //pst = conn.prepareStatement(date1);
    //DateTime ret1=formatter.parseDateTime(df.format(dateobj));
   // DateTime dt = formatter.parseDateTime(fine);
//days = Days.daysBetween(dt,dt).getDays();
    // int n=ChronoUnit.DAYS.between(fine,fine);
      JOptionPane.showMessageDialog(null,"Days are"+fine);
 }
        }
        catch(Exception e)
        {
             JOptionPane.showMessageDialog(null,"Fine error"+e);
        }
    }                                              

    private void formWindowClosed(java.awt.event.WindowEvent evt) {                                  
        // TODO add your handling code here:
        try{
        conn.commit();
        conn.close();
        }
        catch(Exception e)
        {}
    }                                 
public class Main {
    public static int getDifferenceDays(Date d1, Date d2) {
        int daysdiff=0;
        long diff = d2.getTime() - d1.getTime();
        long diffDays = diff / (24 * 60 * 60 * 1000)+1;
        daysdiff = (int) diffDays;
        return daysdiff;
    }

    public static void main(String[] args) throws ParseException {
        String dateStart = "11/21/2016";
        String dateStop =  "11/22/2016";

        SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");

        Date d1 = format.parse(dateStart);
        Date d2 = format.parse(dateStop);

        System.out.println(getDifferenceDays(d1,d2));
    }
}

如何计算从 milliseconds.one 天开始:24 * 60 * 60 * 1000 = 86400000 毫秒。

example output:
11/21/2016
11/22/2016
Days between: 2