Browse Source

fixed aligned method for custom interval

pull/14253/head
IrynaMatveieva 11 months ago
parent
commit
ed436c1dfa
  1. 8
      common/data/src/main/java/org/thingsboard/server/common/data/cf/configuration/aggregation/single/interval/CustomInterval.java

8
common/data/src/main/java/org/thingsboard/server/common/data/cf/configuration/aggregation/single/interval/CustomInterval.java

@ -55,10 +55,10 @@ public class CustomInterval extends BaseAggInterval {
@Override @Override
protected ZonedDateTime getAlignedBoundary(ZonedDateTime reference, boolean next) { protected ZonedDateTime getAlignedBoundary(ZonedDateTime reference, boolean next) {
long durationMillis = getDurationMillis(); ZonedDateTime localMidnight = reference.toLocalDate().atStartOfDay(reference.getZone());
long nowMillis = reference.toInstant().toEpochMilli(); long secondsFromMidnight = Duration.between(localMidnight, reference).getSeconds();
long alignedStartMillis = (nowMillis / durationMillis) * durationMillis; long alignedSecondsFromMidnight = (secondsFromMidnight / durationSec) * durationSec;
ZonedDateTime aligned = Instant.ofEpochMilli(alignedStartMillis).atZone(getZoneId()); ZonedDateTime aligned = localMidnight.plusSeconds(alignedSecondsFromMidnight);
return next ? aligned.plusSeconds(durationSec) : aligned; return next ? aligned.plusSeconds(durationSec) : aligned;
} }

Loading…
Cancel
Save