Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A Date object capable of storing microseconds

Tags:

java

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...

like image 544
Nim Avatar asked Jan 18 '23 20:01

Nim


1 Answers

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?

like image 166
Jon Skeet Avatar answered Jan 30 '23 08:01

Jon Skeet