Class DateTimeRange

java.lang.Object
cloud.opencode.base.date.range.DateTimeRange

@Deprecated(since="1.0.0", forRemoval=false) public final class DateTimeRange extends Object
Deprecated.
Use LocalDateTimeRange instead
DateTimeRange - Compatibility wrapper for LocalDateTimeRange 日期时间范围 - LocalDateTimeRange的兼容性包装器

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

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

Features | 主要功能:

  • Compatibility wrapper for LocalDateTimeRange - LocalDateTimeRange的兼容性包装器
  • Containment and overlap checking - 包含和重叠检查
  • Intersection, span, and gap operations - 交集、跨度和间隙操作
  • Conversion to other range types - 转换为其他范围类型

Usage Examples | 使用示例:

DateTimeRange range = DateTimeRange.of(
    LocalDateTime.of(2024, 1, 1, 0, 0),
    LocalDateTime.of(2024, 12, 31, 23, 59, 59)
);
Duration duration = range.toDuration();
boolean contains = range.contains(LocalDateTime.now());

Security | 安全性:

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

    • of

      public static DateTimeRange of(LocalDateTime start, LocalDateTime end)
      Deprecated.
      Creates a DateTimeRange 创建日期时间范围
      Parameters:
      start - the start datetime | 起始日期时间
      end - the end datetime | 结束日期时间
      Returns:
      the DateTimeRange | 日期时间范围
    • of

      public static DateTimeRange of(LocalDateTime start, Duration duration)
      Deprecated.
      Creates a DateTimeRange with a duration 使用时长创建日期时间范围
      Parameters:
      start - the start datetime | 起始日期时间
      duration - the duration | 时长
      Returns:
      the DateTimeRange | 日期时间范围
    • empty

      public static DateTimeRange empty()
      Deprecated.
      Creates an empty DateTimeRange at the current time 在当前时间创建空日期时间范围
      Returns:
      empty DateTimeRange | 空日期时间范围
    • empty

      public static DateTimeRange empty(LocalDateTime dateTime)
      Deprecated.
      Creates an empty DateTimeRange at the specified time 在指定时间创建空日期时间范围
      Parameters:
      dateTime - the datetime | 日期时间
      Returns:
      empty DateTimeRange | 空日期时间范围
    • from

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

      public LocalDateTime getStart()
      Deprecated.
    • getEnd

      public LocalDateTime getEnd()
      Deprecated.
    • toDuration

      public Duration toDuration()
      Deprecated.
    • isEmpty

      public boolean isEmpty()
      Deprecated.
    • contains

      public boolean contains(LocalDateTime dateTime)
      Deprecated.
    • overlaps

      public boolean overlaps(DateTimeRange other)
      Deprecated.
    • encloses

      public boolean encloses(DateTimeRange other)
      Deprecated.
    • abuts

      public boolean abuts(DateTimeRange other)
      Deprecated.
    • intersection

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

      public DateTimeRange span(DateTimeRange other)
      Deprecated.
    • gap

      public Optional<DateTimeRange> gap(DateTimeRange other)
      Deprecated.
    • toLocalDateTimeRange

      public LocalDateTimeRange toLocalDateTimeRange()
      Deprecated.
      Converts to LocalDateTimeRange 转换为LocalDateTimeRange
      Returns:
      the LocalDateTimeRange | LocalDateTimeRange
    • toDateRange

      public DateRange toDateRange()
      Deprecated.
      Converts to DateRange (date portion only) 转换为DateRange(仅日期部分)
      Returns:
      the DateRange | 日期范围
    • 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