Class DateRange

java.lang.Object
cloud.opencode.base.date.range.DateRange
All Implemented Interfaces:
Iterable<LocalDate>

@Deprecated(since="1.0.0", forRemoval=false) public final class DateRange extends Object implements Iterable<LocalDate>
Deprecated.
Use LocalDateRange instead
DateRange - Compatibility wrapper for LocalDateRange 日期范围 - LocalDateRange的兼容性包装器

This class provides a compatibility layer for the extra.LocalDateRange class, offering the same functionality with a simpler name for legacy code compatibility.

此类为extra.LocalDateRange类提供兼容层,使用更简单的名称以兼容遗留代码。

Features | 主要功能:

  • Compatibility wrapper for LocalDateRange - LocalDateRange的兼容性包装器
  • Date iteration and streaming - 日期迭代和流式处理
  • Containment and overlap checking - 包含和重叠检查
  • Split by week/month - 按周/月分割

Usage Examples | 使用示例:

DateRange range = DateRange.of(LocalDate.of(2024, 1, 1), LocalDate.of(2024, 12, 31));
long days = range.lengthInDays();
for (LocalDate date : range) {
    System.out.println(date);
}

Security | 安全性:

  • Thread-safe: Yes (immutable, delegates to immutable LocalDateRange) - 线程安全: 是(不可变,委托给不可变的LocalDateRange)
  • Null-safe: No (delegates null handling to LocalDateRange) - 空值安全: 否(空值处理委托给LocalDateRange)
Since:
JDK 25, opencode-base-date V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • of

      public static DateRange of(LocalDate start, LocalDate end)
      Deprecated.
      Creates a DateRange (inclusive on both ends) 创建日期范围(两端都包含)
      Parameters:
      start - the start date | 起始日期
      end - the end date | 结束日期
      Returns:
      the DateRange | 日期范围
    • ofExclusive

      public static DateRange ofExclusive(LocalDate start, LocalDate endExclusive)
      Deprecated.
      Creates a DateRange (exclusive end) 创建日期范围(不包含结束日期)
      Parameters:
      start - the start date | 起始日期
      endExclusive - the end date (exclusive) | 结束日期(不包含)
      Returns:
      the DateRange | 日期范围
    • empty

      public static DateRange empty()
      Deprecated.
      Creates an empty DateRange 创建空日期范围
      Returns:
      empty DateRange | 空日期范围
    • from

      public static DateRange from(LocalDateRange range)
      Deprecated.
      Creates a DateRange from a LocalDateRange 从LocalDateRange创建DateRange
      Parameters:
      range - the LocalDateRange | LocalDateRange
      Returns:
      the DateRange | 日期范围
    • getStart

      public LocalDate getStart()
      Deprecated.
    • getEnd

      public LocalDate getEnd()
      Deprecated.
    • lengthInDays

      public long lengthInDays()
      Deprecated.
    • isEmpty

      public boolean isEmpty()
      Deprecated.
    • contains

      public boolean contains(LocalDate date)
      Deprecated.
    • encloses

      public boolean encloses(DateRange other)
      Deprecated.
    • overlaps

      public boolean overlaps(DateRange other)
      Deprecated.
    • isConnected

      public boolean isConnected(DateRange other)
      Deprecated.
    • intersection

      public Optional<DateRange> intersection(DateRange other)
      Deprecated.
    • span

      public DateRange span(DateRange other)
      Deprecated.
    • iterator

      public Iterator<LocalDate> iterator()
      Deprecated.
      Specified by:
      iterator in interface Iterable<LocalDate>
    • stream

      public Stream<LocalDate> stream()
      Deprecated.
    • stream

      public Stream<LocalDate> stream(Period step)
      Deprecated.
    • toList

      public List<LocalDate> toList()
      Deprecated.
    • splitByWeek

      public List<DateRange> splitByWeek()
      Deprecated.
    • splitByMonth

      public List<DateRange> splitByMonth()
      Deprecated.
    • toLocalDateRange

      public LocalDateRange toLocalDateRange()
      Deprecated.
      Converts to LocalDateRange 转换为LocalDateRange
      Returns:
      the LocalDateRange | LocalDateRange
    • equals

      public boolean equals(Object obj)
      Deprecated.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Deprecated.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Deprecated.
      Overrides:
      toString in class Object