Time Interval: SystemClock. uptimeMillis and System. currentTimeMillis

Source: Internet
Author: User

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
*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.