在没有年份的 Joda Time 中创建日期范围?

Make a date range in Joda Time without the year?

是否可以制作类似于 Joda Time 的间隔 class 的范围对象,您可以在其中设置开始和结束日期值但不包括年份?例如,如果日期在 8 月 1 日和 12 月 1 日之间,我想在我的代码中做一些事情,而不考虑年份。

Joda-Time 提供了一种 MonthDay type that implements ReadablePartial (see the list of implementing classes for more types of partial times). You can combine this with Guava's Range 类型来表示此类间隔的范围。

Joda-Time 不包含处理部分范围的可靠方法;您的时间跨度选项是 Period, Interval, and Duration。然而,我发现 Range 非常适合此类任务。