K
K
kolodach2014-02-08 17:18:51
Java
kolodach, 2014-02-08 17:18:51

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

2 answer(s)
K
kolodach, 2014-02-10
@kolodach

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

M
Marat S, 2014-07-01
@aratj

в чем проблема так сделать ?
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 question

Ask a Question

731 491 924 answers to any question