Hi,

Instead of getting time in 24 hours format you can retrieve them in 12
hours. using the below code.



private TimePickerDialog.OnTimeSetListener myTimeSetListener
        = new TimePickerDialog.OnTimeSetListener(){

            //@Override
            public void onTimeSet(TimePicker view, int hourOfDay, int
minute) {
                // TODO Auto-generated method stub
                String converttime=null;
                try{
                String s = hourOfDay+":"+minute+":00";
                DateFormat f1 = new SimpleDateFormat("hh:mm:ss");
                Date d = f1.parse(s);
                DateFormat f2 = new SimpleDateFormat("h:mm a");
                converttime=f2.format(d).toLowerCase(); // "12:18am"
                }catch(Exception e){

                }


                Toast.makeText(AndroidDatePicker.this, converttime,
                        Toast.LENGTH_LONG).show();
            }
    };


Hope this helps you.

Regrads
Vinay Kumar



On Tue, Sep 25, 2012 at 11:19 AM, Ibrahim Sada <[email protected]>wrote:

>  Mycallback=new OnTimeSetListener() {
>
>         public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
>
>         ViewGroup vg=(ViewGroup) view.getChildAt(0);
>
>             Toast.makeText(TimePickerDemoActivity.this, 
> hourOfDay+":"+minute+":"+((Button)vg.getChildAt(2)).getText().toString(), 
> 5000).show();
>
>         }
>     };
>
>
>
> On 25 September 2012 09:13, sindhu <[email protected]> wrote:
>
>> Hi, how to get time picker am/pm values in android 3.0?
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Android Developers" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/android-developers?hl=en
>
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to