stringtokenizer - Convert time value to format “hh:mm Am/Pm” using Android -


i getting date value database "2013-02-27 06:06:30" using stringtokenizer time separately below

string starttime = "2013-02-27 06:06:30";  stringtokenizer token = new stringtokenizer(starttime);                 string date1 = token.nexttoken();                   string time1 = token.nexttoken();  

and in time1 getting result 06:06:30,

can re-store in variable of type string follows?

string displayvalue = "06:06 am"; 

and if time1 variable has value of

string time = 16:00:00; 

then should converted to:

string displayvalue = "04:00 pm"; 

try this..

date dt = new date(date1); simpledateformat sdf = new simpledateformat("hh:mm aa"); string time1 = sdf.format(dt); 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -