Aryan
Aryan

Reputation: 156

How to get elapsed time from chronometer in form of int

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

Upvotes: 4

Views: 6543

Answers (1)

Ahmed Abidi
Ahmed Abidi

Reputation: 1077

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

int elapsedMillis = (int) (SystemClock.elapsedRealtime() - mChronometer.getBase());

Upvotes: 11

Related Questions