我正在使用SimpleDateFormatter
public static final DateFormat DATE_FORMAT_FULL_FULL_SPACES =
new SimpleDateFormat("dd MMMM yyyy", Locale.getDefault());
and Current Date
当时通过了,它应该显示为1st JULY 2014
其中 st 应该是上标。
我怎样才能走得更远?
创建这些方法
private String getFormatedDate(){
String dayNumberSuffix = getDayNumberSuffix(Calendar.getInstance().get(Calendar.DAY_OF_MONTH));
SimpleDateFormat dateFormat = new SimpleDateFormat(" d'" + dayNumberSuffix + "' MMMM yyyy");
return dateFormat.format(Calendar.getInstance().getTime());
}
private String getDayNumberSuffix(int day) {
if (day >= 11 && day <= 13) {
return "<sup>th</sup>";
}
switch (day % 10) {
case 1:
return "<sup>st</sup>";
case 2:
return "<sup>nd</sup>";
case 3:
return "<sup>rd</sup>";
default:
return "<sup>th</sup>";
}
}
怎么打电话?
String str = getFormatedDate();
txtDate.setText(Html.fromHtml(str));
OutPut :
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)