java.time 中是否有与 Joda-Time Interval 相当的类? [英] Is there a class in java.time comparable to the Joda-Time Interval?
问题描述
我正在评估将我的项目从 Joda-Time 的使用迁移到 java.time 包 在 Java 8.在 Joda-Time 中,我大量使用了 Interval
类.我在 java.time 中找不到这样的东西.
I'm evaluating to migrate my project from the usage of Joda-Time to the java.time package in Java 8. In Joda-Time, I heavily used the Interval
class. I could not find anything like this in java.time.
有类似的课程吗?
推荐答案
抱歉,JSR-310 中没有 JodaTime-Interval-class 的等效项.我怀疑这是否会发生,但项目负责人 Stephen Colebourne 考虑至少在他的外部库 Threeten-Extra 的范围内支持它,请参见 问题.
Sorry for you, there is no equivalent in JSR-310 to JodaTime-Interval-class. I have doubts if this will ever come, but project lead Stephen Colebourne considers at least to support it in the scope of his external library Threeten-Extra, see this issue.
如果您对 JodaTime 感到满意,您应该保留它.并非 JodaTime 中的所有内容都移植到 Java 8(间隔不是唯一的问题).
If you are happy with JodaTime you should keep it. Not everything in JodaTime is ported to Java 8 (Interval is not the only issue).
2014 年 12 月 13 日的更新:
Java-8 中的情况没有改变,但您也可以考虑 Joda-Time 之外的其他外部库.从 v0.9 开始,现在包含一个非常简单的间隔类的 Threeten-Extra(请参阅此处 S. Colebourne 的另一个答案)或我的图书馆 Time4J,它提供 自 v2.0 起的范围包.
The situation in Java-8 has not changed, but you might also consider other external libraries beyond Joda-Time. Either Threeten-Extra which now includes a very simple interval class since v0.9 (see the other answer of S. Colebourne here) or my library Time4J which offers the range package since v2.0.
这篇关于java.time 中是否有与 Joda-Time Interval 相当的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!