我有一个Android应用程序,它返回一个格式化为2014-08-26T16:23:30.803的输入日期 我需要它显示08/16/2014 04:23 pm
这是我的代码
items.add(new ListViewItem()
{{
Ticket = json_data.optString("TicketID");
Desc = json_data.getJSONObject("Location").optString("LocationName");
Status = json_data.optString("Status_Desc");
Poster = json_data.optString("Lastposter");
Time = json_data.optString("Entrydate");
}});
答案 0 :(得分:3)
public static void main(String args[]) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
SimpleDateFormat sdp = new SimpleDateFormat("MM/dd/yyyy hh:mm a");
System.out.println(sdp.format(sdf.parse("2014-08-26T16:23:30.803")));
}
打印:
08/26/2014 04:23 PM
答案 1 :(得分:0)
SimpleDateFormat sd = new SimpleDateFormat("MM'/'dd'/'yyyy hh:mm a");
sd.format(new Date());
答案 2 :(得分:0)
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss a");//dd/MM/yyyy
Date date= new Date("2009-09-22 16:47:08");
String strDate = sdfDate.format(date);
答案 3 :(得分:0)
使用此
SimpleDateFormat formatter = new SimpleDateFormat("dd/MMM/yyyy HH:mm a");
String dateInString = " 2014-08-26T16:23:30.803";
try {
Date date = formatter.parse(dateInString);
System.out.println(date);
System.out.println(formatter.format(date));
} catch (ParseException e) {
e.printStackTrace();
}
它可以帮助你