milin
milin

Reputation: 414

How to implement a Joda DateTime and Duration with fraction milliseconds

I have a requirement to implement a DateTime and Duration object that keeps track of its value using a fractional value. For all intents and purposes, these types should be equivalent to the Joda's DateTime and Duration types, except the millis not 'long'.

How would I go about implementing these types so they are consistent and I get to keep all the niceties Joda brings with it? Is it even possible?

EDIT: To remove ambiguity, by "fractional value", I mean actual fractions, i.e. rational numbers.

Upvotes: 0

Views: 88

Answers (1)

Louis Wasserman
Louis Wasserman

Reputation: 198391

You probably can't get all of the "niceties Joda brings with it."

What you could do -- which Joda might or might not play well with -- is use java.time.Duration, which has nanosecond precision, which is good enough for any application I can conceive of.

Upvotes: 1

Related Questions