Multiple methods for Android to obtain system time
There are many ways to obtain system time in Android, which can be divided into Calendar Class in Java and Java util. The date class implementation, as well as the time implementation in Android.
It is summarized as follows:
Method 1:
Method 2:
Method 3:
Method 4:
Get week date:
Finally, let's talk about date formatting. Date formatting is usually implemented using the simpledateformat class. The date format can't be defined at will, mainly in the following forms:
The date format of code output is: 12-3-22, 4:36 PM
When necessary, it is usually necessary to convert the specific date into milliseconds or timestamp, as follows:
Text - > timestamp, date - > timestamp
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.