Time in Android: Currenttimemillis,uptimemillis,elapsedrealtime

Source: Internet
Author: User

This article links http://blog.csdn.net/xiaodongrush/article/details/28613213

Reference http://developer.android.com/reference/android/os/SystemClock.html

1. The same point and difference of three different time

The same point: both are relative times.
Different points: The baseline for comparison is different. Currenttimemillis can be set by the user through the clock, also can network school, anyway is to set, if not set, how the computer will know how long it is now from January 1, 1970. The other two are calculated after the operating system is booted, but one calculates the depth of sleep time, and the other is not counted.
System#currenttimemillis
Returns the current time in milliseconds since January 1, 1970 00:00:00.0 UTC.
Android.os.systemclock#uptimemillis
Returns milliseconds since boot, not counting time spent in deep sleep.
Android.os.systemclock#elapsedrealtime
Returns milliseconds since boot, including time spent in sleep.

2. Application Scenarios

Alarmmanager supports both the Currenttimemillis and Elapsedrealtime methods.
Thread.Sleep (Millis), object.wait (Millis), Systemclock.sleep (Millis) and handler are all using Uptimemills.

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.