--ADVERTISEMENT--

In this tutorial, you will learn to display the current time using TextClock widget in android application. This widget is introduced in API level 17. You can specify the format pattern 12 hour time format or 24 hour time format and also specify the time zone.

In this TextClock example, I have used two text clocks to display current time in android application, one for default format and another for 12 hour format.

Related:
Android Time Picker Example
Get Current Time in Android Programmatically
Android Date Picker Example

Android TextClock: How to Display Current Time in Android


XML Layout File

res/layout/android_text_clock_example.xml

Java Activity File

src/AndroidTextClock.java

Strings.xml File

res/values/strings.xml

For more about TextClock, visit android developer site.

Now, run your text clock android application to display current time which will look like output given below.

Output:

Display Current Time in Android using TextClock
Android TextClock

Post a Comment

Powered by Blogger.