How to start chronometer in reverse in android?-ThrowExceptions

Exception or error:

timetest = SystemClock.elapsedRealtime();
Log.d("SETTIME: ", ""+timetest);

eltime = SystemClock.elapsedRealtime();
Log.d("ELapsed: ", ""+eltime);

Note: i want to start my chronometer in reverse order. like i set chronometer 10 seconds. now, i want to start from 10 to 0 seconds in reverse order. so can anyone help to get this solution.? Thank you so much in advance.

How to solve:

You can’t, the Chronometer widget only counts up, that’s the specific purpose it was made for. If you want to count down, use the CountDownTimer (the Android SDK page contains a specific example where a TextView is updated), or roll your own solution.

These classes are trivial wrappers to save you some typing. You really shouldn’t feel uncomfortable writing an alternative implementation if they donĀ“t fit your exact needs.


As Ronaldo Bahia added in the remarks, since API 24 the Chronometer actually offers this functionally through the setCountDown method.


You can’t chronometer widget for counts down. use CountDownTimer example below
here my count down start from 01:45 mins 1sec = 1000

 CountDownTimer cT =  new CountDownTimer(100000, 1000) {

         public void onTick(long millisUntilFinished) {

                 String v = String.format("%02d", millisUntilFinished/60000);
                 int va = (int)( (millisUntilFinished%60000)/1000);
                 textView.setText("seconds remaining: " +v+":"+String.format("%02d",va));

         public void onFinish() {


Choronometer only counts up. but we can do reverse with this small trick.

chrono.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
            public void onChronometerTick(Chronometer arg0) {
                countUp = (SystemClock.elapsedRealtime() - startTime) / 1000;

                if (countUp % 2 == 0) {
                } else {
                int min = (int) (countUp/60);
                int sec = (int) (countUp%60);

                int newCount = MAX_TIME - (int) countUp;  // MAIN LOGIC
                String asText = String.format("%02d",(newCount / 60)) + ":"
                        + String.format("%02d", (newCount % 60));

                if (countUp > MAX_TIME) {
                    //time complete


For those who are still looking for other options and a View, I suggest using the Chronometer widget and setting setCountDown (boolean) to true.

As an example, in your activity or fragment:

  view_timer.base = SystemClock.elapsedRealtime() + 10000    

For the widget in the layout .xml:



Also possible to use setCountDown(true);


private static int sec = 60*2;  // this is for 2 for min TODO replace your sec

    public void startTimer(final TextView textView ,int sec) {

    CountDownTimer downTimer= new CountDownTimer(1000 * sec, 1000) {

        public void onTick(long millisUntilFinished) {

            String v = String.format("%02d", millisUntilFinished / 60000);
            int va = (int) ((millisUntilFinished % 60000) / 1000);
            textView.setText(v + ":" + String.format("%02d", va));

        public void onFinish() {


and call this :


Leave a Reply

Your email address will not be published. Required fields are marked *