public static long getStartTimeOfAggregates(long currentTime, TimePeriod.Duration duration, String timeZone) {
        switch (duration) {
            case SECONDS:
                return currentTime - currentTime % getMillisecondsPerDuration(duration);
            case MINUTES:
                return currentTime - currentTime % getMillisecondsPerDuration(duration);
            case HOURS:
                return getStartTimeOfAggregatesForHour(currentTime, timeZone);
            case DAYS:
                return getStartTimeOfAggregatesForDay(currentTime, timeZone);
            case MONTHS:
                return getStartTimeOfAggregatesForMonth(currentTime, timeZone);
            case YEARS:
                return getStartTimeOfAggregatesForYear(currentTime, timeZone);
            default:
                throw new SiddhiAppRuntimeException("Undefined duration " + duration.toString());
        }
    }
Performs time conversions related to incremental aggregation.
modules/siddhi-core/src/main/java/io/siddhi/core/util/IncrementalTimeConverterUtil.java