java calculate time difference

Calculate the difference of 30 days between the two times. 

  String statime = starttime.getText();
    String endtim = endtime.getText();
    
    if(!"".equals(statime)&&!"".equals(endtim)){
     long startLong = stringToDate(statime).getTime() ;
     long endLong= stringToDate(endtim).getTime();     
     int a = (int) ((endLong-startLong)/(24 * 60 * 60 * 1000));     
     if(a>=31){
      MessageDialog.openConfirm(getShell (), "Tips", "The period between the two should be controlled within 1 month");
      return;
     }
    }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326118881&siteId=291194637