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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:03:17+00:00 2026-06-10T11:03:17+00:00

I was about to use System.currentTimeMillis() in Eclipse when I noticed the following paragraph

  • 0

I was about to use System.currentTimeMillis() in Eclipse when I noticed the following paragraph appear in its Javadoc:

Returns the current system time in milliseconds since January 1, 1970
00:00:00 UTC. This method shouldn't be used for measuring timeouts or
other elapsed time measurements, as changing the system time can affect
the results.

So that means I can’t rely on System.currentTimeMillis() if I wanted to specifically maintain a reference to this current point in time. What is the most accurate way to do it, then? Do the three methods mark the current time differently from each other?

UPDATE: What I’m trying to do is measure the difference between two points in time in two separate program runs. My fear is that if I use System.currentTimeMillis() and the user plays with the system time after the first run, I might get a bizarre unexpected value during the second.

  • 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-10T11:03:18+00:00Added an answer on June 10, 2026 at 11:03 am

    If you want to refer to a specific point in time, you can definitely rely on System.currentTimeInMillis(). The three methods you describe will mark the time the same way, the difference is just what kind of object it is wrapped in. Use the variant that you need in your program.

    If you want to measure the difference between two points in time during a program run, use
    System.nanoTime() instead.

    To get the time difference between two points in time in two separate program runs you will have to rely on external time sources if you are afraid that the user might play around with the system clock. For example, you can take a look at Java SNTP Client.

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

Sidebar

Related Questions

I'm trying to use System.Data.Sqlite library, and I'm following the documentation about optimizing inserts
I need to use System.exit(0) in an application. Eclipse has the PMD plugin installed
I'm studying UML and I've been reading about use cases. All of the examples
Im thinking about to use a DB for my logs instead of a normal
I am about to use linqtosql in my first asp.net mvc application. I have
I'm about to use Google's Website Optimizer to do a/b testing on the home
I am wondering about the use of == when comparing two generators For example:
I'm about to use func_get_args for reading additional arguments of a function call. How
I have a question about the use of multidimensional std::intializer_list in C++. I have
I have a question about the use of data structures such as ArrayLists in

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.