Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8475173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:49:26+00:00 2026-06-10T17:49:26+00:00

I have a timer that counts down. I want the displayed format to be

  • 0

I have a timer that counts down. I want the displayed format to be 00.00 or “ss.SS”. However I haven’t made any progress in hours. Without the SimpleDateFormat it displays 01.91 then goes to 01.9. This makes it hard to watch as it flickers to keep the view centered. All I really want is a way to keep the format 01.90 and not allow the 0 to be dropped. Could I accomplish this with my original code without the SimpleDateFormat?

/*
 *  This is my original code before I tried the SimpleDateFormat
 *
 *  This code is fully functional and works good, it just keeps dropping the 0 every
 *     10 milliseconds and makes the view shake
 *
 *  getTimeSecs() could return 5, 10, 15, 30, 90 seconds converted to milliseconds
 *  getCountDownInterval() returns 10
 *  
 */

public void createTimer() {
    myCounter = new CountDownTimer(getTimeSecs(), getCountDownInterval()) {
        public void onTick(long millisUntilFinished) {
        timerIsRunning = true;

            if(millisUntilFinished < 10000) {
                TVcountDown.setText("0" + ((millisUntilFinished / 10) / 100.0));
            } else {
                TVcountDown.setText("" + ((millisUntilFinished / 10) / 100.0));
            }
        } //end onTick()

        @Override
        public void onFinish() {  
            timerIsRunning = false;
            TVcountDown.setBackgroundColor(myRes.getColor(R.color.solid_red));
            TVcountDown.setTextColor(myRes.getColor(R.color.white));
            TVcountDown.setText("Expired");

            // Make sure vibrate feature is enabled
            if(wantsVib == true) {
            vib.vibrate(300);
            }

        } //end onFinish()

    }.start();

} //end createTimer()

Here is my code after trying the SimpleDateFormat

public void createTimer() {
    myCounter = new CountDownTimer(getTimeSecs(), getCountDownInterval()) {
        public void onTick(long millisUntilFinished) {
        timerIsRunning = true;
            long current = (long) ((millisUntilFinished / 10) / 100.0);
            TVcountDown.setText("" + timerDisplay.format(current));
        }

        @Override
        public void onFinish() {  
            timerIsRunning = false;
            TVcountDown.setBackgroundColor(myRes.getColor(R.color.solid_red));
            TVcountDown.setTextColor(myRes.getColor(R.color.white));
            TVcountDown.setText("Expired");

            // Make sure vibrate feature is enabled
            if(wantsVib == true) {
                vib.vibrate(300);
            }

        }

    }.start();

} //end createTimer()

I know! I don’t even think I’m close to getting it with the SimpleDateFormat and I’m getting frustrated. It runs, but counts down only seconds, on the milliseconds side. So 15 seconds shows 00.15 not 15.00.

I don’t expect someone to code it all out for me just need pointed in the right direction. All the tutorials I can find involve years, days, and such and I can’t grasp the concept from that.

I’d prefer not to use the SimpleDateFormat — cuz it hasn’t been to simple for me — and just use my original code and add a zero to the end of the milliseconds side every 10 milliseconds.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:49:28+00:00Added an answer on June 10, 2026 at 5:49 pm

    Try this:

    TVcountDown.setText(convertToMyFormat(millisUntilFinished));
    

    and convertToMyFormat() method:

    public String convertToMyFormat(long ms) {
        String secString, msecString;
        //constructing the sec format:
        int sec = (int) (ms / 1000);
        if(sec < 10)        secString = "0"+sec;
        else if(sec == 0)   secString = "00";
        else                secString = ""+sec;
        //constructing the msec format:
        int msec = (int) ((ms-(sec*1000))/10.0);
        if(msec < 10)       msecString = "0"+msec;
        else if(msec == 0)  msecString = "00";
        else                msecString = ""+msec;
    
        return secString+":"+msecString;
    }
    

    I’m not sure if I did the msec part correctly but you can tweek it as you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery timer on my page that counts down from 10 to
I have created a javascript timer that starts at 40 and counts down by
I want to have a counter that counts down from 60 seconds to 0.
I have a count down timer that beeps every second it counts through AVAudioPlayer.
I have a repeating timer that runs down a clock. During the clock running
I want to create a timer in PHP that will count down every second.
I have a function that counts how many times a words appears on a
I have a function (frequency) which that counts how many times each distinct value
For example I have an app that counts how many time Camera button was
I have a timer that needs to not process its elapsed event handler at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.