HairlessGorilla
Lurker
I am adding a clock to my app but whenever the tens minute is at 0 (eg. 11:05) it will not display the tens minute (eg. 11:5). How do I fix this?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
import java.util.Calendar
Calendar rightNow = Calendar.getInstance();
int nHour = rightNow.get(Calendar.HOUR_OF_DAY);
int nMinutes = rightNow.get(Calendar.MINUTE);
int nSeconds = rightNow.get(Calendar.SECOND);
String strClock = String.format("%02d:%02d:%02d", nHour, nMinute, nSecond);
I tried using that code and it worked, however, it only shows the time the app was started and doesn't change. is there a way of making it always show the correct time?Do you mean that your clock string will show '11:5' rather than '11:05' when the time is 11:05?
If so, the codes as below are for your reference.
Code:import java.util.Calendar Calendar rightNow = Calendar.getInstance(); int nHour = rightNow.get(Calendar.HOUR_OF_DAY); int nMinutes = rightNow.get(Calendar.MINUTE); int nSeconds = rightNow.get(Calendar.SECOND); String strClock = String.format("%02d:%02d:%02d", nHour, nMinute, nSecond);
timer...I tried using that code and it worked, however, it only shows the time the app was started and doesn't change. is there a way of making it always show the correct time?