Announcement Announcement Module
Collapse
No announcement yet.
Why does Auditable require Joda Time Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why does Auditable require Joda Time

    Hi,
    I am looking at Auditable and I came across the fact that it requires Joda Time - what's the technical necessity of that? I'm thinking that many projects do not use Joda Time and do not have the flexibility to just introduce it as a dependency, and while the library is indeed good, it's unfortunatelly not standard. So my question is - wouldn't it be better to just use Date (or any other solution that doesn't require introducing a completely new library)?
    The advantage of that would be keeping Spring Data general and appliable in more environments than just the ones that have Joda Time.
    Thanks.
    Eugen.

  • #2
    You've pretty much stated the reason in a (IMHO) way to positive way: Date just sucks and I wouldn't advice anyone to use it. I've been sick of the inaccessability, complexity and thread-safety issues that came up up over and over again. Beyond that JodaTime (or at least it's derivative) is going to become the new standard Java date time API. This was proposed for Java 7 already but has been postponed unfortunately.

    You might wanna have a look at [0] where we outline a re-thought (annotation based) approach to the auditing API that might support both Date and DateTime as well as being more flexible about what is being set (maybe only dates, only users, only creation, only modification etc.).

    [0] https://jira.springsource.org/browse/DATAJPA-116

    Comment


    • #3
      I agree with the general idea of making something better, or using the better alternative and I fully agree that Date is not the best API out there. However, two things I would add - first, we're just talking about the interface - there's nothing prevening the actual logic of the application to make full use of joda time - there are excelent conversions options between Date and DateTime, so using Date in the interface doesn't mean that we have to use Date in the entire system.
      Second, I want to again stress that Date is the standard - introducing joda time is likely not an option for most projects, and this decision greatly restricts the usecase of the audit fetures in Spring Data, which is unfortunate but also very unexpected. I say unexpected because I'm sure that there may be other examples were some custom library may be better than the default one, but usually Spring first has support for the default use case and then adds support for the non default ones, and does so in a transparent and non-intrusive way.
      In conclusion, my thinking on this is that, at least a corresponding (similar) interface should be added to use Date (alongside this one), so that at least we have the option to choose. When Java 8 comes along, JSR 310 should help, but pragmatically (and unfortunatelly) we're not there yet, and it would be more usefull to acknoledege that reality rather than ignore it.
      Thanks a lot for the feedback.
      Eugen.

      Comment

      Working...
      X