Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get elapsed time from chronometer in form of int

Tags:

java

android

I have a chronometer and am using mChronometer.getText();how do I convert this to an int? using Integer.parseInt(); throws an error because mChronometer.getText(); outputs in the form minutes : seconds

like image 304
Aryan Avatar asked Dec 19 '22 10:12

Aryan


1 Answers

if you are using android.widget.Chronometer you can get the elapsed time with :

int elapsedMillis = (int) (SystemClock.elapsedRealtime() - mChronometer.getBase());
like image 164
Ahmed Abidi Avatar answered Jan 05 '23 00:01

Ahmed Abidi