java - Not able to properly display time in AM, PM format in Android -
i have achieved time formate using am-pm below code
date date = new simpledateformat("h:m").parse((mhour+":"+mminute)); string newstring = new simpledateformat("hh:mm a").format(date); system.out.println("time - "+newstring); but in above code there 1 problem
if set time 12:00 am in timepickerdialog display 12:00 am if change time in timepickerdialog 12:00 pm still display 12:00 am
it's because h 12 hour time format. , timepickerdialog sending 24 hour format.
use,
date date = new simpledateformat("h:m").parse((mhour+":"+mminute)); // upper h here. edit:
simpledateformat java doc, check out date , time patterns section.
Comments
Post a Comment