Time range with START and END in Java

Viewed 4606

Is there any standard Java implementation to represent a time range with FROM and TO? Actually I am using the following class.

I also looked at Instant.range() or Period, which are both not defining a time range or span, but calculating the duration of a period instead of saving the exact time range with FROM and TO.

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;
  }
}
0 Answers
Related