Alex Rivera | Logout

Joda DateTime vs Instant

Asked 2012-01-03T22:33:42.793
25

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?

Edit
Report

1 Answer

29

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?

answered 2012-01-03T22:39:58.800

Your Answer