public static long getPreviousStartTime(long currentStartTime, TimePeriod.Duration duration) {
        switch (duration) {
            case SECONDS:
                return currentStartTime - getMillisecondsPerDuration(duration);
            case MINUTES:
                return currentStartTime - getMillisecondsPerDuration(duration);
            case HOURS:
                return currentStartTime - getMillisecondsPerDuration(duration);
            case DAYS:
                return currentStartTime - getMillisecondsPerDuration(duration);
            case MONTHS:
                return getStartTimeOfPreviousMonth(currentStartTime);
            case YEARS:
                return getStartTimeOfPreviousYear(currentStartTime);
            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