that gets microsecond timestamps, but beware that will not necessarilly get you microsecond precision as the nanosecond time method doesn't guarantee nanosecond precision (depending on operating system if might get precision of 20 microseconds or worse, this is due to restrictions of the system the JVM is running on rather than the JVM itself).
To get that you'll need an external API of some sorts, probably depending on JNI code and a hardware timing device.
> System.nanoTime is no way related to the system
> clock. Its the system timer. It wont helpe me out in
> this.
> I need the system time to get loggeg with
> microseconds.
> I dont want to go for JNI and call a c code.
> Is there a way?
no, there isn't.
You'll need external hardware to provide the required precision, and unless that hardware comes with a Java library to access it (which would use JNI internally almost certainly) you're not going to do this.
Same for other languages, those too would need an external source to provide the precision you require.
> > I'm sure System.currentTimeMillis() is all the OP
> > needs here...
>
> Ah, another of your illinformed idiocies.
> Pray how will currentTimeMillis ever return
> microsecond precision?
Microsecond precision was not requested. Just a microsecond count. Given the vagueness of the question, I'd say he currentTimeMillis() * 1000 response is valid - I'd even concur.
> Microsecond precision was not requested. Just
> a microsecond count. Given the vagueness of the
> question, I'd say he currentTimeMillis() * 1000
> response is valid - I'd even concur.
right, i also assumed the OP just needed a simple timer and so often I see people recommending insanely complex solutions when it's not necessary (such as using JNI). thanks for backing me up. and thanks jwenting for your usual cr@p, i hope it makes you feel good