Method one can use the GetTime () method of date to convert the time of the current date format to the number of milliseconds and subtract from it.
Long systime = new Date (). GetTime ();//Current system time
Long oldtime = Old.gettime ();//Comparison of time
Long time = (systime-oldtime);//Millisecond of difference
Method two uses the calendar's Gettimeinmillis () method to convert the time of the current date format to the number of milliseconds.
Calendar nowdate=calendar.getinstance ();
Calendar olddate=calendar.getinstance ();
Nowdate.settime (New Date ());//set to current system time
Olddate.settime (old);//set to the date you want to compare
Long Timenow=nowdate.gettimeinmillis ();
Long Timeold=olddate.gettimeinmillis ();
Long time = (timenow-timeold);//Millisecond of difference
The number of milliseconds to get a two-day difference can get two dates apart in a few days when a few seconds.
Java gets two milliseconds of a date difference