Reputation: 33
I have an android application that returns an Entry date Formatted like this 2014-08-26T16:23:30.803 I need it to display 08/16/2014 04:23 pm
Here is my code
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");
}});
Upvotes: 0
Views: 104
Reputation: 56
use this
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();
}
it helps you
Upvotes: 0
Reputation: 3682
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")));
}
prints:
08/26/2014 04:23 PM
Upvotes: 3
Reputation: 1135
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);
Upvotes: 0
Reputation: 15708
SimpleDateFormat sd = new SimpleDateFormat("MM'/'dd'/'yyyy hh:mm a");
sd.format(new Date());
Upvotes: 0