java 判断两个日期相差多少天

2024-11-30 05:45:10
推荐回答(1个)
回答1:

publicstaticlongdaysBetween(Dated1,Dated2){if((d1==null)||(d2==null)){return0;}longld1=d1.getTime();longld2=d2.getTime();longdays=(long)((ld2-ld1)/86400000);returndays;}