Java method for obtaining timestamp accurate to seconds
This example shares the specific code of Android Jiugongge picture display for your reference. The specific contents are as follows
1. Introduction to timestamp:
Definition of timestamp: it is usually a character sequence that uniquely identifies the time of a moment. Digital time stamp technology is a variant of digital signature technology. It refers to the total number of seconds from 00:00:00 GMT on January 1, 1970 (08:00:00 GMT on January 1, 1970) to the present (quoted from Baidu Encyclopedia)
2. Timestamp in Java:
In different development languages, the length of the time stamp obtained is different. For example, the time stamp in C + + is accurate to seconds, but the time stamp in Java is accurate to milliseconds. In this way, in the development process involving different languages, if it is not unified, there will be some problems of inaccurate time.
3. There are two methods in Java to obtain time stamps accurate to seconds:
The milliseconds of timestamp in Java are mainly measured by the last three bits. We remove the last three bits in two different ways.
Method 1: through string The substring () method removes the last three bits
Method 2: remove the last three digits by integer division
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.