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

  • Home
  • SEARCH
  • 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 8994571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:27:45+00:00 2026-06-15T23:27:45+00:00

I have a count down timer that works fine except for I’m geting numbers

  • 0

I have a count down timer that works fine except for I’m geting numbers that have more then 2 digits for the 100th of seconds. I’m creating 2 calendar objects, bgetting there time alue in milli secons, and subtracting it. code

    long milsecs1= calendar1.getTimeInMillis();
    long milsecs2 = calendar2.getTimeInMillis();

    long diff = milsecs2 - milsecs1;
    long dsecs = diff / 1000;

    long ddays = diff / (24 * 60 * 60 * 1000);  
    diff=diff-ddays *(24 * 60 * 60 * 1000); 
    textDays.setText(   Integer.toString( (int)ddays)+":" );

    long dhours = diff / (60 * 60 * 1000);
    diff=diff-dhours* (60 * 60 * 1000);
    textHours.setText(   Integer.toString( (int)dhours)+":" );

    long dminutes = diff / (60 * 1000);
    diff=diff-dminutes* (60 * 1000);
    textMinuts.setText(   Integer.toString( (int)dminutes)+":" );

/////////////////////////////////////////////////
// THIS IS THE PART THAT IS NOT WORKING, I WANT NUMBERS 0-99, BUT GETTING NUMBERS LIKE 230
    long dseconds = diff / (100);
    textSeconds.setText(   Integer.toString( (int)dseconds)+":" );
    diff=diff-dseconds;
  • 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-15T23:27:46+00:00Added an answer on June 15, 2026 at 11:27 pm

    Joda time provides a much simpler (and thoroughly proven) solution in its Period class. Something like this should do the trick (untested):

    Period period = new Period(calendar1.getTimeInMillis(), calendar2.getTimeInMillis());
    int days = period.getDays();
    int hours = period.getHours();
    ... etc.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a timer that counts down every second. It works great until the
I’m trying to create a count down timer. I user a Timer object that
Interesting problem! Basically I have a timer for my UI that counts down from
I have a timer that counts down. I want the displayed format to be
i have one count down timer using http://keith-wood.name/countdown.html var austDay = new Date(); austDay
I want to create a timer in PHP that will count down every second.
I have a timer that counts down every second. The timer is used for
I have a CountdownTimer that counts down from 60 seconds. This CountdownTimer works by
I have a timer class set up that is basically handling all of count
I have a timer that runs on the website. It will retrieve a timespan

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.