我有出生日期多个联系人,所有被同步到移动设备上。现在的问题是所有联系人都有不同格式的生日,我想显示如DD-MM-YYYY特定格式的所有生日日期。
I have multiple contacts with birth dates and all are synced with the mobile device. Now the problem is all contacts have different birthday formats and i want to display all of the birthday dates in a specific format like "dd-MM-yyyy".
所以例如,一个同步的联系人具有生日像1990年2月7日或1988-06-15T22:00:00.000Z或1990年12月2号等... 那么所有这些日期的应显示在一个特定的格式为DD-MM-YYYY。
so for example one synchronized contact has birthday like "1990-02-07" or "1988-06-15T22:00:00.000Z" or "12-02-1990" etc... then all of these dates should be displayed in a specific format "dd-MM-yyyy".
那么,如何实现这一问题的解决方案?
So how can I achieve this issue with solution?
任何建议将AP preciated。
Any suggestion will be appreciated.
只需用的SimpleDateFormat类。是这样的:
Simply using SimpleDateFormat class. Something like:
Date d = Calendar.getInstance().getTime(); // Current time
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); // Set your date format
String currentData = sdf.format(d); // Get Date String according to date format
在这里你可以查看详细信息和所有支持的格式为:
Here you can see details and all supported format:
http://developer.android.com/reference/java/text/SimpleDateFormat.html
下一篇:加密第 3 方凭据凭据