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 8976311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:06:07+00:00 2026-06-15T19:06:07+00:00

I am using countdown timer in my application where i need to display upcoming

  • 0

I am using countdown timer in my application where i need to display upcoming date in days hours minutes and seconds left.I got the days,hours,minutes and seconds but when i set it to text view the countdown doesn’t start.The below is my code.

Date date = new Date(2013,Integer.parseInt(datess.get(k).split("-")[1])-1,Integer.parseInt(datess.get(k).split("-")[0]),hours,mins,secs);  
     long dtMili = System.currentTimeMillis();  
     Date dateNow = new Date(dtMili);  
      remain = date.getTime() - dateNow.getTime();


MyCount counter = new MyCount(remain,1000);
            counter.start();

public class MyCount extends CountDownTimer{
    public MyCount(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
        }



    @Override
    public void onFinish() {
        // TODO Auto-generated method stub

        tv3.setText("done");
    }

    @Override
    public void onTick(long millisUntilFinished) {
        // TODO Auto-generated method stub


        tv3.setText(timeCalculate(millisUntilFinished/1000) + " Countdown");

    }
}

 public String timeCalculate(long ttime)   
   {  
     long  daysuuu,hoursuuu, minutesuuu, secondsuuu;  
     String daysT = "", restT = "";  



     daysuuu = (Math.round(ttime) / 86400);  
     hoursuuu = (Math.round(ttime) / 3600) - (daysuuu * 24);  
     minutesuuu = (Math.round(ttime) / 60) - (daysuuu * 1440) - (hoursuuu * 60);  
     secondsuuu = Math.round(ttime) % 60;  


     if(daysuuu==1) daysT = String.format("%d day ", daysuuu);  
     if(daysuuu>1) daysT = String.format("%d days ", daysuuu);  

     restT = String.format("%02d:%02d:%02d", hoursuuu, minutesuuu, secondsuuu);  

     return daysT + restT;  
   }  

This is the output

enter image description here

Why is the countdown not started? Any Suggestions are appreciated.

  • 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-15T19:06:08+00:00Added an answer on June 15, 2026 at 7:06 pm

    You are not using the millisUntilFinished parameter to update your time in timeCalculate(). Start with:

    @Override
    public void onTick(long millisUntilFinished) {
        tv3.setText(millisUntilFinished + " Countdown");
    }
    

    Once you’ve confirmed that the timer is working, you’ll need a method to convert millisUntilFinished into a human readable String.

    The classes related to dates and times in Java are unnecessarily difficult to work with and have some obscure errors. (For instance much of the Date class is deprecated, but the recommended Calendar class still relies on Date heavily…) The 3rd party library Joda Time is a popular replacement.


    Addition

    the output is not what i expected

    25,000 to 700 days in the future is not what I would expect either, date appears to be wrong. As gabriel points out in another answer to this question the year value is calculated from 1900. Though something else is still wrong since 25,000 days is less than 70 years in the future…
    However this constructor is deprecated and shouldn’t be used, Calendar is the recommended class. I wrote a quick demo using Calendar for you.

    But understand that CountDownTimer itself has a couple fundamental flaws:

    • Every time onTick() is called CDT adds a few milliseconds to the overall time, I noticed that it can easily add 7 and half minutes every day.
    • Because of the first error the last onTick() might no be called. When counting down from 5, I typically see "5, 4, 3, 2, <long pause>" then onFinished() displays "0"…

    I rewrote CDT in a previous question: android CountDownTimer – additional milliseconds delay between ticks.

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

Sidebar

Related Questions

I am using http://nithinbekal.com/2009/javascript-how-to-create-a-simple-countdown-timer/ But when I run it in firefox I get the
I'm a relative Android newbie writing a timer application. I'm using a custom countdown
I'm writing simple pomodoro application, which is basically countdown timer. Right now, I've got
I'm using a jquery countdown timer and it works everywhere, even in IE7 but
I tried using this JavaScript countdown timer on my page but the timer won't
I have coded a simple PHP Countdown Timer using this code: list($date,$time)=explode( ,$compounddate); list($thour,$tminute,$tsecond)=explode(:,$time);
Using NSTimer for my application in which I have to show countdown timer with
Im using the code below to display a countdown timer on a webpage. If
I was creating a countdown timer using javascript; I can use jQuery. I want
I'm using node.js and socket.io to display countdown timers. The timers are being run

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.