In many cases, whether we use time intervals to do some algorithms or call system APIs, such as animation effects, we need to do so based on time intervals. The common practice is to record the start time of startTime, the system then obtains the current time currentTime for each callback and calculates the difference value = currentTime-startTime. The system provides two methods to obtain the current time:
SystemClock. uptimeMillis and System. currentTimeMillis
What are the differences between the two methods?
1. SystemClock. uptimeMillis () // The number of milliseconds from the boot to the present (the sleep time of the mobile phone is not included );
2. System. currentTimeMillis () // Number of milliseconds from January 1, January 1, 1970 UTC to the present;
However, 2nd times can be modified through System. setCurrentTimeMillis. In some cases, once modified, the time interval will be inaccurate.
Note: AnimationUtils clearly states:
[Java]
/**
* Returns the current animation time in milliseconds.
* This time shoshould be used when invoking
* {@ Link Animation # setStartTime (long)}. Refer
* {@ Link android. OS. SystemClock} for more
* Information about the different available clocks.
* The clock used by this method is
* <Em> not </em> the "wall" clock (it is not
* {@ Link System # currentTimeMillis }).
*
* @ Return the current animation time in milliseconds
*
* @ See android. OS. SystemClock
*/