如果在 Java 8 发布之前,我肯定会选择 nscala-time 作为我的 scala play 项目。
但是自从 Java 8 发布以来,建议在 Java 项目中使用 Java 8 数据和时间而不是 joda 时间。
那么 Scala 项目怎么样?我们应该坚持使用 nscala-time 还是 switch?如果使用Java 8日期和时间,需要使用mutable。
还有,哪个库对play json库有很好的支持?
最佳答案
Java 8 时间库 ( java.time
) 类型是不可变的; Joda Time 实际上有一些针对特定用例的可变类。还有a Scala wrapper对于 java.time
它可以与 java.time
的向后移植一起使用对于 Java 7。我没有 Play JSON 的经验,但根据 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
block 引用>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
所以目前看来使用 nscala-time (或直接 Joda)更有意义,特别是如果您使用 Play 的其他部分,而不仅仅是 JSON。
关于java - nscala-time 和 Java 8 数据时间之间的 Scala 日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32708732/