Java 8 LocalDateTime.now() only giving precision of milliseconds
<p>Is it possible to get microseconds in Java 8? The Java 8 <code>LocalDateTime</code> class has a <code>.getNano()</code> method which is meant to return <code>nanoseconds</code>, but on both Linux(Ubuntu) and OS X (10.11.5) it only returns <code>milliseconds</code> (when I ran it it returned <code>301000000</code> which equals <code>301 milliseconds</code>) and I really need to be able to get <code>microseconds</code>.</p>
<p>I know that it is possible to get <code>nanoseconds</code> (and therefore get <code>microseconds</code> from it) on my computer as the javascript method <code>process.hrtime()</code> returns a precise value.</p>
<p>Before anyone starts a precise vs. accurate argument I know that nanoseconds is completely unreliable between threads and shouldn't be used for comparison.</p>
<p><strong>Edit</strong>:</p>
<p>To be clear the <code>LocalDateTime</code> class is part of the Java 8 <code>java.time</code> set of classes.</p>
<p><strong>Update</strong>:</p>
<p>So I realised that Javascript's <code>process.hrtime</code> is like Java's <code>System.nanoTime()</code> and isn't actually related to the wall clock, it's time since some arbitrary value which are different between the two languages.</p>
<p>New question: Is there a way that I can parse clock time from these values? Ie. If I get <code>System.currentTimeMillis()</code> and <code>System.nanoTime()</code>, and compare that to another set of those values could I get the actual time of the second set of values?</p>
<p>My problem is that I need to do logging using both Java and Javascript and they need to have a consistent microsecond field across both of them.</p>