Java 8 Date and Time API 是否弃用了 Joda Time?(java.time) [英] Is Joda Time deprecated with java 8 Date and Time API? (java.time)

查看:32
本文介绍了Java 8 Date and Time API 是否弃用了 Joda Time?(java.time)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我可以使用 Java 8 日期和时间 API (java.time),是否有任何理由使用 Joda Time?
我应该每次都使用 Java 8 日期和时间吗?

Is there any reason to use Joda Time if I can use Java 8 Date and Time API (java.time)?
Should I use Java 8 Date and Time every time?

推荐答案

Joda-time 的作者本人的官方声明是Java-8 可用后立即迁移.另请参阅 网站 中的引用:

The official statement of the author of Joda-time himself is to migrate as soon as Java-8 is available. See also this citation from the website:

请注意,Joda-Time 被认为是一个很大程度上已完成"的项目.没有计划进行重大改进.如果使用 Java SE 8,请迁移到 java.time (JSR-310).

Note that Joda-Time is considered to be a largely "finished" project. No major enhancements are planned. If using Java SE 8, please migrate to java.time (JSR-310).

所以对您的问题的简短回答是:是(已弃用).但是,请记住,Java-8 中不提供某些功能,例如 Joda-IntervalPeriodTypePeriodFormatter,因此您必须编写自己部分丑陋的解决方法,另见我的 SO-post 关于 Joda-Time 和 JSR-310 之间的差异.

So the short answer to your question is: YES (deprecated). However, keep in mind that some features like Joda-Interval or PeriodType or PeriodFormatter are not available in Java-8 so you have to write your own partially ugly workarounds, see also my SO-post about differences between Joda-Time and JSR-310.

关于两个图书馆未来的附言:

Side remarks about the future of both libraries:

在这种情况下,完成"是什么意思?

好吧,您可以将 Joda-issue 254 与我的 Twitter 上的小讨论.我认为人们应该对 Joda-Time 的任何重大改进寄予厚望.还请考虑到 Joda-Time 未来的开发资源是有限的(人手不足).老实说:自 2008 年 Joda-Time 以来的大多数版本都具有错误修复版本的特征(2.0 除外).

Well, you can compare the Joda-issue 254 with my small discussion on Twitter. I think people should rather set down their expectations to any major enhancement of Joda-Time. Please also consider that the future development resources regarding Joda-Time are limited (lack of manpower). And let's be honest: Most releases since Joda-Time in year 2008 rather have the character of bugfix releases (with the exception of 2.0).

另一方面:JSR-310的创新速度也可能不会很高(因为它已经很大了,而且因为Oracle在这里是决定性的参与者,一般不考虑日期时间库作为任何 Java 版本的核心基石).因此,将来总会有一些空间留给外部库来提供缺失的功能,例如(按字母顺序):

On the other side: The innovation speed of JSR-310 will probably not be very high, too (because it is already big, and because Oracle is here the decisive player and a date-time-library is in general not considered as the central cornerstone of any Java-release). So there is always some space left for an external library in the future to supply missing features, for example (in alphabetical order):

  • Threeten-Extra(作为 Basil Bourque 的最爱,见他的评论)
  • Time4J(我自己的扩展,2015 年夏天解决了互操作性问题)
  • Threeten-Extra (as the favourite of Basil Bourque, see his comment)
  • Time4J (my own extension, interoperability issue solved in summer 2015)

这篇关于Java 8 Date and Time API 是否弃用了 Joda Time?(java.time)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆