Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove seconds and AM/PM from Digital clock widget

Tags:

android

I want to remove the seconds and AM/PM indication from the digital clock widget but I don't know how to do this.

like image 418
Peter Avatar asked Dec 21 '22 19:12

Peter


1 Answers

It is hard-coded in the DigitalClock class, so you can't change it programatically. The only way to change it is to re-implement DigitalClock widget. Yo can get source code from here.

You need to copy this code in your project, rename it like "MyDigitalClock" and use this one as your widget. As you will see in the implementation, there are two variables you should focus on to get what you want:

private final static String m12 = "h:mm:ss aa";
private final static String m24 = "k:mm:ss";

ss represents seconds and aa represents am/pm.

like image 153
Erol Avatar answered Feb 24 '23 07:02

Erol