This article shares the specific code for Android nine-grid picture display for your reference. The specific content is as follows
1. Introduction to timestamp:
Definition of timestamps: Usually a sequence of characters that uniquely identifies the time of a certain moment. Digital timestamp technology is an application of a variant of digital signature technology. It refers to the total number of seconds from 00:00:00 on January 1, 1970 Greenwich time (08:00:00 on January 1, 1970 Beijing time) to the present (cited from Baidu Encyclopedia)
2. Timestamp in Java:
In different development languages, the length of the obtained timestamps are different. For example, the timestamps in C++ are accurate to seconds, but the timestamps in Java are accurate to milliseconds. In this way, if there is no unified system, some time inaccuracy will occur.
3. Two methods in Java to obtain timestamps that are accurate to seconds:
The milliseconds of timestamps in Java are mainly measured through the last three digits, and we remove the last three digits in two different ways.
Method 1: Remove the last three digits through String.substring() method
/** * Get the timestamp accurate to seconds* @return */ public static int getSecondTimestamp(Date date){ if (null == date) { return 0; } String timestamp = String.valueOf(date.getTime()); int length = timestamp.length(); if (length > 3) { return Integer.valueOf(timestamp.substring(0,length-3)); } else { return 0; } } Method 2: Remove the last three digits by dividing them
/** * Get the timestamp accurate to seconds* @param date * @return */ public static int getSecondTimestampTwo(Date date){ if (null == date) { return 0; } String timestamp = String.valueOf(date.getTime()/1000); return Integer.valueOf(timestamp); }The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.