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
    21,101
    Thanks
    52
    Thanked 2,285 Times in 2,256 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
    746
    Thanks
    0
    Thanked 134 Times in 117 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,781
    My Mood
    Mellow
    Thanks
    236
    Thanked 717 Times in 703 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, 05:02 AM
  5. Tikal Eclipse - Moving system time
    By leguin in forum Java IDEs
    Replies: 2
    Last Post: December 3rd, 2009, 12:34 AM