Calendar c1=Calendar.getInstance();
c1.set(2020, 5, 10);
Calendar c2=Calendar.getInstance();
c2.set(2020,5, 2);
long c=c1.getTime().getTime()-c2.getTime().getTime();
long day=c/(24*60*60*1000);//一天的时间
System.out.println(day+1);
第一个getTime()转成date型,第二个getTime换成毫秒数