private Long[] getStartTimeEndTime(String singleWithinTimeAsString) {
        long startTime;
        long endTime;
        String timeZone;
        List<Pattern> supportedPatterns = getSupportedRegexPatterns(singleWithinTimeAsString.length());
        if (supportedPatterns == null) {
            throw new SiddhiAppRuntimeException("Incorrect format provided for within clause. "
                    + "Supported formats for non GMT timezones are <yyyy>-**-** **:**:** <ZZ>, "
                    + "<yyyy>-<MM>-** **:**:** <ZZ>, " + "<yyyy>-<MM>-<dd> **:**:** <ZZ>, "
                    + "<yyyy>-<MM>-<dd> <HH>:**:** <ZZ>, " + "<yyyy>-<MM>-<dd> <HH>:<mm>:** <ZZ>, and "
                    + "<yyyy>-<MM>-<dd> <HH>:<mm>:<ss> <ZZ>. The ISO 8601 UTC offset must be provided for "
                    + "<ZZ> (ex. +05:30, -11:00). For GMT timezone the same formats must be adhered to, without <ZZ>. "
                    + "However the given format is " + singleWithinTimeAsString);
        }
        for (int i = 0; i < TimePeriod.Duration.values().length; i++) {
            if (supportedPatterns.get(i).matcher(singleWithinTimeAsString).matches()) {
                switch (i) {
                    case 0:
                        startTime = IncrementalUnixTimeFunctionExecutor.getUnixTimeStamp(singleWithinTimeAsString);
                        endTime = startTime + 1000;
                        return new Long[]{startTime, endTime};
                    case 1:
                        startTime = IncrementalUnixTimeFunctionExecutor
                                .getUnixTimeStamp(singleWithinTimeAsString.replaceAll("\\*", "0"));
                        endTime = startTime + 60000;
                        return new Long[]{startTime, endTime};
                    case 2:
                        startTime = IncrementalUnixTimeFunctionExecutor
                                .getUnixTimeStamp(singleWithinTimeAsString.replaceAll("\\*", "0"));
                        endTime = startTime + 3600000;
                        return new Long[]{startTime, endTime};
                    case 3:
                        startTime = IncrementalUnixTimeFunctionExecutor
                                .getUnixTimeStamp(singleWithinTimeAsString.replaceAll("\\*", "0"));
                        endTime = startTime + 86400000;
                        return new Long[]{startTime, endTime};
                    case 4:
                        startTime = IncrementalUnixTimeFunctionExecutor.getUnixTimeStamp(
                                singleWithinTimeAsString.
                                        replaceFirst("\\*\\*\\s\\*\\*[:]\\*\\*[:]\\*\\*", "01 00:00:00"));
                        timeZone = IncrementalTimeGetTimeZone.getTimeZone(
                                singleWithinTimeAsString.
                                        replaceFirst("\\*\\*\\s\\*\\*[:]\\*\\*[:]\\*\\*", "01 00:00:00"));
                        endTime = IncrementalTimeConverterUtil.getNextEmitTime(startTime, TimePeriod.Duration.MONTHS,
                                timeZone);
                        return new Long[]{startTime, endTime};
                    case 5:
                        startTime = IncrementalUnixTimeFunctionExecutor.getUnixTimeStamp(singleWithinTimeAsString
                                .replaceFirst("\\*\\*-\\*\\*\\s\\*\\*[:]\\*\\*[:]\\*\\*", "01-01 00:00:00"));
                        timeZone = IncrementalTimeGetTimeZone.getTimeZone(singleWithinTimeAsString
                                .replaceFirst("\\*\\*-\\*\\*\\s\\*\\*[:]\\*\\*[:]\\*\\*", "01-01 00:00:00"));
                        endTime = IncrementalTimeConverterUtil.getNextEmitTime(startTime, TimePeriod.Duration.YEARS,
                                timeZone);
                        return new Long[]{startTime, endTime};
                    default:
                        // Won't occur since there are only 6 TimePeriod.Durations (sec, min, hour, day, month, year)
                }
            }
        }
        throw new SiddhiAppRuntimeException("Incorrect format provided for within clause. "
                + "Supported formats for non GMT timezones are <yyyy>-**-** **:**:** <ZZ>, "
                + "<yyyy>-<MM>-** **:**:** <ZZ>, " + "<yyyy>-<MM>-<dd> **:**:** <ZZ>, "
                + "<yyyy>-<MM>-<dd> <HH>:**:** <ZZ>, " + "<yyyy>-<MM>-<dd> <HH>:<mm>:** <ZZ>, and "
                + "<yyyy>-<MM>-<dd> <HH>:<mm>:<ss> <ZZ>. The ISO 8601 UTC offset must be provided for "
                + "<ZZ> (ex. +05:30, -11:00). For GMT timezone the same formats must be adhered to, without <ZZ>. "
                + "However the given format is " + singleWithinTimeAsString);
    }
Executor class for finding the start time and end time of the within clause in incremental processing.
This is important when retrieving incremental aggregate values by specifying a time range with 'within' clause.
modules/siddhi-core/src/main/java/io/siddhi/core/executor/incremental/IncrementalStartTimeEndTimeFunctionExecutor.java