java - nscala-time 和 Java 8 数据时间之间的 Scala 日期时间

标签 java scala playframework jodatime nscala-time

如果在 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

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/

相关文章:

java - 如何在android蓝牙通讯中写一个字符?

java - JNI - C++/Java 中的监听器 - 是否可以在 C++ 中实例化 Java 对象并将它们用作参数

scala - Shapeless:迭代联积中的类型

java - 混淆生成 jsse 的私钥和公钥?

java - 在 jframe 上显示列表

scala - 如何在 phantom-dsl 中连续更新多个字段?

使用案例类/伴随对象模式时的 Scala 依赖注入(inject)

java - Play Framework REST API 调用

java - Playframework 2.4 Java - 默认 "play-java"模板需要 1 分钟以上才能运行/不热重载

playframework - com.typesafe.config.ConfigException$缺少 : No configuration setting found for key 'play.application'