java.time 中是否有类与 Joda-Time Interval 相当?

2023-12-31

我正在评估将我的项目从使用中迁移乔达时间 http://www.joda.org/joda-time/ to the java.time包 http://docs.oracle.com/javase/8/docs/api/java/time/package-summary.html in Java 8 https://en.wikipedia.org/wiki/Java_version_history#Java_SE_8_.28March_18.2C_2014.29。在 Joda-Time 中,我大量使用了Interval http://www.joda.org/joda-time/apidocs/org/joda/time/Interval.html班级。我在 java.time 中找不到类似的东西。

有类似的班级吗?


抱歉,JSR-310 中没有 JodaTime-Interval-class 的等效项。我怀疑这是否会到来,但项目负责人 Stephen Colebourne 考虑至少在他的外部库 Threeten-Extra 的范围内支持它,请参阅此issue https://github.com/ThreeTen/threeten-extra/issues/2.

如果您对 JodaTime 感到满意,您应该保留它。并非 JodaTime 中的所有内容都移植到 Java 8(间隔不是唯一的问题)。

2014年12月13日更新:

Java-8 中的情况没有改变,但您也可以考虑 Joda-Time 之外的其他外部库。要么 Threeten-Extra 自 v0.9 起包含一个非常简单的间隔类(请参阅此处 S. Colebourne 的其他答案),要么我的库 Time4J 提供范围包 https://github.com/MenoData/Time4J/tree/master/range/src/main/java/net/time4j/range自 v2.0 起。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

java.time 中是否有类与 Joda-Time Interval 相当? 的相关文章

随机推荐