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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:54:44+00:00 2026-06-15T08:54:44+00:00

I need stopWatch and I used http://www.goldb.org/stopwatchjava.html It did not work well so I

  • 0

I need stopWatch and I used http://www.goldb.org/stopwatchjava.html

It did not work well so I tried write out the value every 1000ms:

stopWatch.start();
HandlerScrollBar.postDelayed(TtScroll,  1000);

private Runnable TtScroll = new Runnable() {
    public void run() {
        long time = stopWatch.getElapsedTime();
        HandlerScrollBar.postDelayed(TtScroll,(long) 1000);
        Log.d(TAG, Long.toString(time));            
    }
};

I can see value of time every second in CatLog and this is result:

enter image description here

Real time is max +5ms but in Column it is at least +3 seconds! How is it possible? It is the same with

new Date().getTime().

Is there some StopWatch class which will pass this test as expected?

Thank you.

  • 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-15T08:54:45+00:00Added an answer on June 15, 2026 at 8:54 am

    If you are measuring elapsed time, and you want it to be correct, you must use System.nanoTime(). You cannot use System.currentTimeMillis(), unless you don’t mind your result being wrong.

    The purpose of nanoTime is to measure elapsed time, and the purpose of currentTimeMillis is to measure wall-clock time. You can’t use the one for the other purpose. The reason is that no computer’s clock is perfect; it always drifts and occasionally needs to be corrected.

    Since nanoTime’s purpose is to measure elapsed time, it is unaffected by any of these small corrections.I would suggest to pick the nanoTime() as it has better accuracy in those microcalculations.

    for extremely precise measurements of elapsed time. From its javadoc:

    long startTime = System.nanoTime(); 
    

    // … the code being measured …

    long estimatedTime = System.nanoTime() - startTime;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use this stopwatch (or something similar): http://www.sivamdesign.com/scripts/dwld/stopwtch.txt but I will need
I need to replace Stopwatch to avoid using getters for its properties. I am
I need to calculate the time taken to execute each thread. So I used
I need an accurate timer, and DateTime.Now seems not accurate enough. From the descriptions
i need to create stopwatch with start,stop and pause in android. please assist me.
I need shows the timer running in console. I use stopwatch: System.Diagnostics.Stopwatch stopwatch =
I doing simple stopwatch. I have StopwatchActivity.java I have ListAdapter but i need set
I am constantly drawing frames, and I need the form to not flicker. How
I need a stopwatch/timer to countdown. I'm trying to use Kellis Havers stopwatch jQuery
First of all, Console.ReadKey() is not the answer. I need to be able to

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.