Java 中 START 和 END 的时间范围

ale*_*lex 6 java time

是否有任何标准 Java 实现来表示FROMTO的时间范围?实际上我正在使用以下课程。

我还查看了Instant.range()Period,它们都没有定义时间范围或跨度,而是计算一个时间段的持续时间,而不是使用FROMTO保存确切的时间范围。

public class TimeRange {

  private Instant from, to;

  public TimeRange(Instant from, Instant to) {
     this.from = from;
     this.to = to;
  }

  public Instant getFrom() {
     return from;
  }

  public void setFrom(Instant from) {
     this.from = from;
  }

  public Instant getTo() {
     return to;
  }

  public void setTo(Instant to) {
     this.to = to;
  }

  public boolean isProperlySet() {
     return from != null && to != null;
  }
}
Run Code Online (Sandbox Code Playgroud)