Chronometer formatting to always show hours

572 Views Asked by At

So I've been trying to set the chronometer's format to "HH:MM:SS" but I haven't been able to. Tried just doing this chrono.setText("00:00:00") but when you start it, goes back to 00:00. Also tried this `

chronoM.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener()
     {
            @Override
            public void onChronometerTick(Chronometer chronometer)
            {
                long time = SystemClock.elapsedRealtime() - chronometer.getBase();

                Date date = new Date(time);

                DateFormat formatter = new SimpleDateFormat("HH:mm:ss");

                String dateFormat = formatter.format(date);

                chronometer.setText(dateFormat);
            }
        });`

Everything was fine until I pressed start. The second I pressed start went from 00:00:00 to 20:00:00. The timer was running fine, but I couldn't get rid of that 20 and since I copied this from another question, I wasn't sure how it worked.

I was wondering, is their a better way to do this? If I leave it in the default format "00:00" does it eventually reach hours? If it does then I'll just leave it like that and work with what I got.

Thanks in advance.

0

There are 0 best solutions below