0

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");
}});
user3267471
  • 33
  • 11
  • possible duplicate of [How do you format date and time in Android?](http://stackoverflow.com/questions/454315/how-do-you-format-date-and-time-in-android). And [this](http://stackoverflow.com/q/2201925/642706) and many others. – Basil Bourque Sep 16 '14 at 06:14

4 Answers4

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")));
    }

prints:

08/26/2014 04:23 PM
user3487063
  • 3,672
  • 1
  • 17
  • 24
0
SimpleDateFormat sd = new SimpleDateFormat("MM'/'dd'/'yyyy hh:mm a");
sd.format(new Date());
sol4me
  • 15,233
  • 5
  • 34
  • 34
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);
Kannan Thangadurai
  • 1,117
  • 2
  • 17
  • 36
0

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

Dondaldo
  • 56
  • 5