Analog & Digital


Analog & Digital


One of the popular widgets in Android is the clock. It is available in two different variants, Analog and Digital. Both the variants are capable of display the current time for the device. By default, the clock cannot change the time on the device. However, we can use “Timepicker”, and “Datepicker”. This can be easily created in the Android Studio. The sample code for the Analog and Digital clock is shown below.

While you create the Analog and Digital clock in Android, you have to remember that Analog is a subclass of the View class, whereas digital is a subclass of TextView class. The AnalogClock is a two-handed clock, with one hand indicating the hour and the other the minute. The DigitalClock resembles a traditional digital clock, displaying hours, minutes, and seconds in digital format.

The android.widget.AnalogClock and android.widget.DigitalClock classes display analog and digital clocks, respectively.

  • Analog clock: The View class has a subclass called Analog clock. It's a clock with a circular face. Numbers 1 to 12 appear around the circle to symbolize the hour, and two hands are employed to denote the instant of time—the shorter one for the hour and the longer one for the minutes.
  • Digital clock: The time is displayed in "HH:MM" format using digits in a digital clock, a TextView class subclass.