TextClock

The TextClock provides a date/time in two formats, one is to show the date/time in 24 Hours format and another one is to show the date / time in 12-hour format. By using the is24HourModeEnabled() method, we can easily know whether the system using TextClock in 24 Hours format or 12 Hours format.

public class TextClock extends TextView
java.lang.Object
↳ android.view.View
  ↳ android.widget.TextView
    ↳ android.widget.TextClock


Create TextClock in xml:

<TextClock
    android:id="@+id/txtClock"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:format12Hour="hh:mm:ss a"
    tools:targetApi="jelly_bean_mr1" />


Attributes Description
android:format12Hour Specifies the formatting pattern used to show the time and/or date in 12-hour mode.
android:format24Hour Specifies the formatting pattern used to show the time and/or date in 24-hour mode.
android:timeZone Specifies the time zone to use.