转换日期字符串perticular日期格式" DD-MM-YYYY"在java中 [英] convert date string to perticular date format "dd-MM-yyyy" in java
问题描述
我有出生日期多个联系人,所有被同步到移动设备上。现在的问题是所有联系人都有不同格式的生日,我想显示如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:
<一个href="http://developer.android.com/reference/java/text/SimpleDateFormat.html">http://developer.android.com/reference/java/text/SimpleDateFormat.html
这篇关于转换日期字符串perticular日期格式&QUOT; DD-MM-YYYY&QUOT;在java中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!