How is joda-time different from java time?

490    Asked by MarieBroadber in Java , Asked on Oct 11, 2022

 Although Joda is feature rich and more sophisticated than standard Java time, it may not always be the best thing to use. How do I decide if I should use Joda Time or Java Time in any Java code?

Is there some kind of guideline which tells us how to pick the right one depending on our requirements?

Answered by Mark Sullivan

Joda-Time is such an improvement over the Java time library that it is almost always the right choice, apart from the following exceptions:

When it is difficult or undesirable to add third party dependencies to your project

When its use in a public interface would cause issues, e.g. getting an ORM to handle both java and Joda time fields

However, in the case of 2) it would still be better to use Joda internally if possible.

The above things are worth keeping in mind, but should be rare. If in doubt, go with Joda.



Your Answer

Interviews

Parent Categories