android - How to convert time in 12 hr format? -


i'm getting call time through cursor , want display in 12 hr format instead of 24 hr format.

here code time cursor

string calldate = managedcursor.getstring(dateindex); date calldaytime = new date(long.valueof(calldate)); 

and set call day time text view

lastintreactionvaluetv.settext(calldaytime+""); 

it's showing like

thu jun 26 14:36:24 edt 2014 

what should convert 12 hr format?

use simpledateformat set format need, example:

    date calldaytime  = new date();     dateformat sdf= new simpledateformat("eee, mmm dd kk:mm:ss z yyyy",new locale("en"));     system.out.println(sdf.format(calldaytime) ); 

this output:

thu, jun 26 08:54:51 cest 2014


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -