javascalaplayframeworkjodatimenscala-time

Scala datetime between nscala-time and Java 8 data time


If before Java 8 releases, definitely I will choose nscala-time for my scala play project.

However since Java 8 releases, recommending using Java 8 data and time instead of joda time for Java project.

So how about for Scala project? Should we stick using nscala-time or switch? If using Java 8 date and time, need to use mutable.

Also, which library has good support for play json library?


Solution

  • Java 8 time library (java.time) types are immutable; Joda Time actually has some mutable classes for specific use-cases. There is also a Scala wrapper for java.time which can be used together with a backport of java.time for Java 7. I have no experience with Play JSON, but according to the mailing list,

    We should consider migrating to the JSR-310 types internally in Play 3.0 and recommending using java.time._ types in the documentation. It seems like the Reads/Writes implementations we have for those are pretty reasonable. We just need to make sure we add support for those types in other parts of the APIs

    But, currently at least the implementation in 2.4.2 for java.time.Instant Reads/Writes is buggy and I'm trying to get this fixed. So, maybe you want to join the discussion here: https://groups.google.com/forum/#!topic/play-framework/VFMTGPCW7Hc

    so it seems using nscala-time (or Joda directly) makes more sense for now, especially if you use other parts of Play, not just JSON.