class DateTimeUtils extends TimeUtils {

    public static long[] parseRepeatableDateTime(String dateTimeStr) {
        long[] result = new long[3];
        if (isRepeatable(Objects.requireNonNull(dateTimeStr, "Date-time string cannot be a null value!"))) {

            String[] parsed = parseISORepeatable(dateTimeStr);
            String repeats = parsed[0];
            String delayIn = parsed[1];
            String periodIn = parsed[2];

            Duration startAtDelayDur = null;
            Duration period = null;

            if (DateTimeUtils.isPeriod(delayIn)) {
                // If delay is specified as duration then period variable carry end time information
                OffsetDateTime endTime = OffsetDateTime.parse(periodIn, DateTimeFormatter.ISO_DATE_TIME);
                period = Duration.parse(delayIn);
                startAtDelayDur = Duration.between(OffsetDateTime.now(), endTime.minus(period));
            } else if (DateTimeUtils.isPeriod(periodIn)) {
                // If period is specified as duration then delay variable carry start time information
                OffsetDateTime startTime = OffsetDateTime.parse(delayIn, DateTimeFormatter.ISO_DATE_TIME);
                period = Duration.parse(periodIn);
                startAtDelayDur = Duration.between(OffsetDateTime.now(), startTime);
            } else {
                // Both delay and period are specified as start and end times
                OffsetDateTime startTime = OffsetDateTime.parse(delayIn, DateTimeFormatter.ISO_DATE_TIME);
                OffsetDateTime endTime = OffsetDateTime.parse(periodIn, DateTimeFormatter.ISO_DATE_TIME);
                startAtDelayDur = Duration.between(OffsetDateTime.now(), startTime);
                period = Duration.between(startTime, endTime);
            }

            if (startAtDelayDur.isNegative() || startAtDelayDur.isZero()) {
                // need to introduce delay to allow all initialization
                startAtDelayDur = Duration.of(1, ChronoUnit.SECONDS);
            }

            result[0] = Long.parseLong(repeats.length() == 0 ? "-1" : repeats);
            result[1] = startAtDelayDur.toMillis();
            result[2] = period.toMillis();

            return result;
        } else {

            int index = dateTimeStr.indexOf("###");
            if (index != -1) {
                String period = dateTimeStr.substring(index + 3);
                String delay = dateTimeStr.substring(0, index);
                result = new long[]{TimeUtils.parseTimeString(delay), TimeUtils.parseTimeString(period)};

                return result;
            }
            result = new long[]{TimeUtils.parseTimeString(dateTimeStr)};
            return result;
        }
    }

}