-3

Linux time man page specifies that the clock time structure contains nanoseconds since epoch. Is this exposed in Java in any api ? In other words , why is there no JDK api like System.currentNanos() that returns nanos since Epoch ?

Note : I know System.nanoTime() returns nanos , but its NOT with reference to Epoch time , and cannot be used across VMs for time comparison.

Edit : I am not asking how to format a date value - I am asking how to query the system for nanotime SINCE epoch ?

Bhaskar
  • 7,443
  • 5
  • 39
  • 51
  • http://stackoverflow.com/a/11871217/2161954 – SnakeDoc Feb 04 '16 at 20:24
  • Possible duplicate of [Java time since the epoch](http://stackoverflow.com/questions/11871120/java-time-since-the-epoch) – SnakeDoc Feb 04 '16 at 20:25
  • @SnakeDoc - please read the question carefully before commenting arbitrarily. – Bhaskar Feb 04 '16 at 22:20
  • This is how SO has become - so sad. What is wrong with this question for downvote ? Completely clueless people commenting/ and downvoting here. – Bhaskar Feb 04 '16 at 23:19
  • the only time a Linux box knows is time since Epoch, so Java will return that. Further, if your system is using NTP, it should be more-or-less accurate. So, use the link I provided, and modify to suit your needs. – SnakeDoc Feb 05 '16 at 00:20
  • and, don't go on some rant about what's wrong with SO when you haven't even bothered to read the link resource i've provided, or bothered to actually understand what you are asking for. your question isn't somehow unique or special, it's a fairly common need. – SnakeDoc Feb 05 '16 at 00:24
  • If nano won't work, you'll need to use milliseconds and convert to nano. if not precise enough, use JNA/JNI to call into C. all this was explained in the link. – SnakeDoc Feb 05 '16 at 00:41

1 Answers1

-1

Because Java is intended to work across a whole variety of devices, it is not so closely tied to any one such platform.

John Hascall
  • 9,176
  • 6
  • 48
  • 72