zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package Method;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
public class Dell_Calendar {
 
    /**¼ÆËã2¸öÈÕÆÚÏà²îµÄÌìÊýÄê-ÔÂ-ÈÕ¸ñʽ*/
     public static int daysBetween(String startime,String endtime){
            SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
            Calendar cal = Calendar.getInstance();  
            try {
                cal.setTime(sdf.parse(startime));
            } catch (ParseException e) {
                // TODO ×Ô¶¯Éú³ÉµÄ catch ¿é
                e.printStackTrace();
            }  
            long time1 = cal.getTimeInMillis();               
            try {
                cal.setTime(sdf.parse(endtime));
            } catch (ParseException e) {
                // TODO ×Ô¶¯Éú³ÉµÄ catch ¿é
                e.printStackTrace();
            }  
            long time2 = cal.getTimeInMillis();       
            long between_days=(time2-time1)/(1000*3600*24);
              
           return Integer.parseInt(String.valueOf(between_days));   
        }
     
 
 
    
}