Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: How to get system time in java?

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    1
    My Mood
    Fine
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to get system time in java?

    Hello everyone,
    I just want to calculate search time for my algorithm .Can any one tell me how to get system time in java other than System.nanotime() and System.currenttimemillis() as these methods does not returns consistent time for same input is their another option to get system time???


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: How to get system time in java?

    does not returns consistent time for the same input
    Please explain what the problem is? Timing the execution of a program can depend on what else the OS is doing.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: How to get system time in java?

    The most precise way is System.nanoseconds(). But I have no idea what you mean you say it is not consistent.

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: How to get system time in java?

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

Similar Threads

  1. Patching Java on my system
    By Algernon in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 14th, 2014, 11:19 AM
  2. Using Date() to get Start Time and Finish Time of a copyFiles method
    By dalythe in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: June 17th, 2013, 09:50 PM
  3. [SOLVED] New to java, need to know how to incorparate system time into a block of code.
    By lostbit in forum Java Theory & Questions
    Replies: 5
    Last Post: September 29th, 2011, 07:46 AM
  4. online system on java
    By u-khan1 in forum Paid Java Projects
    Replies: 0
    Last Post: March 8th, 2011, 06:02 AM
  5. Tikal Eclipse - Moving system time
    By leguin in forum Java IDEs
    Replies: 2
    Last Post: December 3rd, 2009, 01:34 AM