I have a timepicker that is in 24 hours format. Now I want to display the current device time in 24 hours format regardless of the device time format. Right now my device is in 12 hours format so for example my time is 2:04 pm the timepicker should be 14:04.
Here's my code or the timepicker. It is on a different layout because I'm displaying them on a dialog.
XML:
<LinearLayout android:id="@+id/datetimepickerLayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="10dp" xmlns:android="http://schemas.android.com/apk/res/android">
<DatePicker android:id="@+id/datePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"></DatePicker>
<TimePicker android:id="@+id/timePicker1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center"></TimePicker>
<Button
android:id="@+id/setdatetimeBtn1"
android:text="Set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_gravity="center"/>
Now in my java code:
timePicker1 = (TimePicker)dialog.findViewById(R.id.timePicker1);
datePicker1 = (DatePicker)dialog.findViewById(R.id.datePicker1);
setDateTimeBtn1 = (Button)dialog.findViewById(R.id.setdatetimeBtn1);
datePicker1.setCalendarViewShown(false);
timePicker1.setIs24HourView(true);
Any ideas? Thanks!