免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
在Android中獲取當前日期的4種方法

In this tutorial I will show you 4 different ways to get current date in android.

在本教程中,我將向您展示4種不同的方法來獲取android中的當前日期。

For doing this we will use Calendar, Date, SimpleDateFormate and System class.

為此,我們將使用Calendar,Date,SimpleDateFormate和System類。

如何在Android中獲取當前日期? (How to Get Current Date in Android?)

Method 1:

方法1:

In this method we will use Calendar and SimpleDateFormate class.

在此方法中,我們將使用Calendar和SimpleDateFormate類。

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");Calendar c = Calendar.getInstance();String date = sdf.format(c.getTime());

Method 2:

方法2:

We can use Calendar class to get current date in another way.

我們可以使用Calendar類以另一種方式獲取當前日期。

Calendar c = Calendar.getInstance();int day = c.get(Calendar.DAY_OF_MONTH);int month = c.get(Calendar.MONTH);int year = c.get(Calendar.YEAR);String date = day + "/" + (month+1) + "/" + year;

Method 3:

方法3:

In this method we will use Date and SimpleDateFormate class.

在此方法中,我們將使用Date和SimpleDateFormate類。

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");String date = sdf.format(new Date());

Method 4:

方法4:

Another method in which we will use System and SimpleDateFormate class to get current date

我們將使用System和SimpleDateFormate類獲取當前日期的另一種方法

SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");String date = sdf.format(System.currentTimeMillis());

Comment below if you know any other way to get current date in android.

如果您知道在Android中獲取當前日期的任何其他方法,請在下面評論。

本站僅提供存儲服務,所有內容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權內容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
android 設置日期
Spring下單例模式與線程安全之間的矛盾解決
Android中Calendar與Date的區(qū)別以及消除時區(qū)對日期操作影響的方法 | 傳說...
淺談JAVA時間日期處理函數(shù)
java獲取當月的第一天或最后一天
java日期增加一個月或減少一天
更多類似文章 >>
生活服務
分享 收藏 導長圖 關注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服