Date startDate;
Date endDate;
long diff = endDate.getTime() - startDate.getTime();
//以天数为单位取整
Long day = diff / (1000 *60 *60 *24);
//以小时为单位取整
Long hour=(diff/(60*60*1000)-day*24);
//以分钟为单位取整
Long min=((diff/(60*1000))-day*24*60-hour*60);
//以秒为单位
Long second=(diff/1000-day*24*60*60-hour*60*60-min*60);
Log.e(“tag”,“day =” +day);
Log.e(“tag”,“hour =” +hour);
Log.e(“tag”,“min =” +min);
Log.e(“tag”,“second =” +second);