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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:32:13+00:00 2026-05-26T11:32:13+00:00

It seems System.currentTimeMillis is not very accurate. See this sample: public class MillisTime {

  • 0

It seems System.currentTimeMillis is not very accurate.

See this sample:

public class MillisTime {
    public static void main(String[] args) {
        long start = 0;
        long end = 0;
        while (true) {
            if (start == 0) {
                start = System.currentTimeMillis();
            } else {
                long current = System.currentTimeMillis();
                if (current != start) {
                    end = current;
                    break;
                }
            }
        }
        System.out.println("The time interval of your OS: " + (end - start) + "ms");
    }
}

The result is (on Windows XP):

The time interval of your OS: 15ms

Why it’s not 1ms? And how to get accurate millis second of current time?

  • 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-05-26T11:32:14+00:00Added an answer on May 26, 2026 at 11:32 am

    This is entirely expected. You’d see the same thing on .NET using DateTime.Now. (See Eric Lippert’s blog post on the topic for a .NET-oriented view on this same topic.)

    You can use System.nanoTime() to get a more accurate timer for measurements only – that’s not meant to give an absolute time, it’s only for measuring intervals.

    I don’t know of any way to get a more accurate absolute time, either from Java or from Win32. To be honest, how accurate is the system clock going to be anyway? Even with regular syncing with an NTP server I’d expect at least a few milliseconds inaccuracy.

    Basically, if you’re relying on getting an absolute time really accurately, you should probably change your design.

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

Sidebar

Related Questions

This seems to work fine in C#: class A : System.Attribute { public A()
It seems to not get past this step: [ 16%] Building CXX object src/CMakeFiles/hphp_runtime_static.dir/lib/system/gen/sys/dynamic_table_func.no.cpp.o
Give the following (straight-forward) code: public class pr1 { public static void f1(){ long
It seems that the System.Diagnostics.Debug , and System.Diagnostics.Trace are largely the same, with the
It seems that MSMQ doesn't use any Database management system to manage messages. How
It seems that I can't control the NSApp delegate from within a System Preferences
On a SQL Server 2000 system, I have a templog.ldf file that seems to
I just upgraded my operating system to Windows 7. Visual Studio 2008 also seems
I've been doing some performance testing around the use of System.Diagnostics.Debug, and it seems
Seems that requirements on safety do not seem to like systems that use AI

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.