Kala J Kala J - 10 days ago 8
Android Question

How can I set my textClock to phone's default time format?

I have my TextClock Set as the following:

<TextClock
android:id="@+id/datetime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_row="1"
android:layout_column="2"
android:textColor="@color/black"
android:format24Hour="HH:mm"
android:format12Hour="HH:mm"
/>


Right now even though my phone is defaulted to a 12 hour time, it's showing up as a 24 hour time.

I want to be able to set it to a 12 hour time zone but not permanently, only in regards to whatever my phone is set as. How can I do that?

EDIT:

I removed the format above but I am setting it again in the code like:

TextClock textClock = (TextClock) findViewById(R.id.datetime);
textClock.setFormat12Hour("HH:mm");
textClock.setFormat24Hour("HH:mm");


Would this also affect the phone's time zone?

I want to remove the AM/PM from the textclock when a format is not set in XML.

Answer
 <TextClock
            android:format12Hour="hh:mm"
            android:format24Hour="kk:mm"

            android:textSize="20sp"
            android:shadowColor="#7fffffff"
            android:shadowRadius="3.0"

            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

I used This code it is not showing me am/pm on my device.