Displaying the Time in AM/PM format in android

Posted by Rahul Varma on Stack Overflow See other posts from Stack Overflow or by Rahul Varma
Published on 2010-04-09T06:25:24Z Indexed on 2010/04/09 6:33 UTC
Read the original article Hit count: 331

Filed under:

Hi,

I am getting the time using a time picker and displaying the time in the text view using following code...

 private TimePickerDialog.OnTimeSetListener mTimeSetListener =

new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int hourOfDay, int minute) { Toast.makeText(SendMail.this, "Your Appointment time is "+hourOfDay+":"+minute, Toast.LENGTH_SHORT).show(); TextView datehid = (TextView)findViewById(R.id.timehidden); datehid.setText(String.valueOf(hourOfDay)+ ":"+(String.valueOf(minute)));

} };

Now, the issue is when i set the time as 8:00 pm then i get the time displayed as 20:0... I want to display the time as 8:00 pm... How can i do that???

© Stack Overflow or respective owner

Related posts about android-sdk