我是显示日期和时间格式为 2013年6月18号12点41分24秒。 但是,我怎么能更改,如格式的 18军,2013下午12时41 我该如何改变机器人?格式
i am displaying the date and time format is 2013-06-18 12:41:24. But how can i change the format like 18-jun-2013 12:41 pm how do I change the format in android?
下面正code
public String parseDateToddMMyyyy(String time) {
String inputPattern = "yyyy-MM-dd HH:mm:ss";
String outputPattern = "dd-MMM-yyyy h:mm a";
SimpleDateFormat inputFormat = new SimpleDateFormat(inputPattern);
SimpleDateFormat outputFormat = new SimpleDateFormat(outputPattern);
Date date = null;
String str = null;
try {
date = inputFormat.parse(time);
str = outputFormat.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
return str;
}
文档:的SimpleDateFormat | Android开发者