Detailed explanation of time stamp in Android

Source: Internet
Author: User

Detailed explanation of time stamp in Android:
(1). Definition:
A timestamp is a set of random numbers that are generated based on the current system time.
(2). function:
As a basis for judging the uniqueness of data. Avoid the error of repeating data changes!
(3). Application:
(1).In the Bank Account table, set the timestamp field timestamp to the text type varchar.
(2).When bank a reads the deposit field in the Account table, it also reads the timestamp field, such as 123456.
(3).When bank a modifies the value of the deposit, the previous read timestamp of 123456 is compared with the timestamp in the current table, and if it is consistent, it is allowed to save and then generate a new timestamp such as 456789 of the time stamp in the replacement table 123456.
If no time stamp is used:
Bank A and Bank B open your account at the same time, and the amount you see is 1000 yuan. At the same time, two banks read a timestamp of 12345.
if using timestamp:
When bank a opened the account, the 1000 yuan to 1500 yuan, save, the system will compare the previous time stamp and save the table when the time stamp is consistent, now consistent, allow disk. When you save the disk, a new timestamp of 45678 is generated. b Bank also changed 1000 yuan to 1500 yuan, save, the system compared with the previous timestamp 123456 is the time stamp in the table when the same, found that the previous time stamp 123456 has been different from the current time stamp 456789, the system refused to disk, the request to refresh data, After the data refresh 1000 yuan already because before a bank deposited 500 yuan and became 1500 yuan, then Bank B will be on the basis of 1500 yuan to 2000 yuan, save again, the system allows.
Nutshell:The time stamp in the data table before the modification is consistent with the timestamp in the data table after the modification.
If consistent, allow storage and generate a new timestamp at the same time.
If not, the data needs to be refreshed and modified on the new data. Store again.
(4). Use:
long timestamp = System.currenttimemillis ();

Detailed explanation of time stamp in Android

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.