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.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>