Files
perfdb/pdb-utils/src/main/java/org/lucares/utils/EndOfInterval.java
Andreas Huber 10155f9cdb use special enum for DateBucket units
Preparation step for having custom intervals.
2020-09-27 17:06:27 +02:00

26 lines
679 B
Java

package org.lucares.utils;
import java.time.temporal.ChronoUnit;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAdjuster;
public class EndOfInterval implements TemporalAdjuster {
private final DateBucketUnit unit;
public EndOfInterval(final DateBucketUnit unit) {
this.unit = unit;
}
@Override
public Temporal adjustInto(final Temporal temporal) {
Temporal result = temporal;
final BeginningOfNextInterval beginningOfnextInterval = new BeginningOfNextInterval(unit);
result = result.with(beginningOfnextInterval);
result = result.minus(1, ChronoUnit.NANOS);
return result;
}
}