Nim Nim - 2 months ago 15
Java Question

A Date object capable of storing microseconds

I'm looking for a Date object capable of storing down to microsecond granularity, does anyone know of one? The standard

Date
object only stores down to milliseconds (I know that this is a platform limitation) and I could get around this by wrapping a
Date
plus a fractional quantity in a custom class. However I was hoping to avoid having to write one with the appropriate calculations etc. I need to parse a
boost::ptime
timestamp in Java and not loose the precision...

Answer

JSR-310 is in alpha stage, but may be useful to you anyway. (Unfortunately it's predecessor, Joda Time, only stores as far as milliseconds.)

java.sql.Timestamp stores values down to nanoseconds, but doesn't help in terms of calculations. What calculations do you need to perform?