Answer the question
In order to leave comments, you need to log in
How to set Cronometr android sdk time output?
I am making an application one of the functions of which is time tracking. I use the standard Chronometer widget
, but its standard output format (MM:SS) does not suit me. I need the format (HH:MM:SS.mm). Tell me how can this be done?
Answer the question
In order to leave comments, you need to log in
I read it adds just an inscription and after the %s sign adds a stopwatch, for example, time is: %s, it will display time is: 6:28
в чем проблема так сделать ?
onStart()
StartTime = System.currentTimeMillis();
...
OnChronometerTickListener
...
long elapsedTimeMills = System.currentTimeMillis() - StartTime
final long sec = elapsedTimeMills / 1000;
final int hours = (int) sec / 3600;
final int min = (int) (sec % 3600) / 60;
final int seconds = (int) sec % 60;
txtTimer.setText(String.format("%02d:%02d:%02d", hours, min, seconds));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question