EJB programming & troubleshooting: How do I get nanos in system time?

  1. How do I get nanos in system time? (1 messages)

    I am calling System.currentTimeMillis() to get the current time. Is there an API that will return a java.sql.Timestamp upto nanoseconds (instead of millis)?
  2. How do I get nanos in system time?[ Go to top ]

    JDK1.5 added the "System.nanoTime()" method to return the the current system time (as accurate as the OS can determine) in nanoseconds. If think the real-time spec for Java also provides something similar, although I haven't looked at it in a long time.

    You should know that most operatings systems probably don't have accuracy of over 1ms anyway, so the "System.nanoTime()" methods wouldn't be any more accurate than "System.currentTimeMillis()". No guarantee is made for the accuracy of "System.nanoTime()". So this method would only make a difference in real-time operating systems.