DD.
DD.

Reputation: 21971

Joda DateTime vs Instant

I'm using Joda, and I'm making a class to store the timestamp for a transaction and persist to a DB. Should I be using an Instant or a DateTime?

Upvotes: 25

Views: 8404

Answers (1)

skaffman
skaffman

Reputation: 403441

Use whichever one best fits your model. Instant is a representation of a millisecond timestamp value, DateTime is a calendar-based object. Each one can be easily converted into the other, so there's no need to restrict your model according what the database needs.

So you need to ask yourself - what data am I actually modelling? Is it a year/month/day/hour/minute/second/etc value, or is it just an arbitrary moment in time with no particular meaning?

Upvotes: 29

Related Questions