public static List<Integer> getSplitBeginIndexes(TimeSeries series, Duration splitDuration) {
        ArrayList<Integer> beginIndexes = new ArrayList<>();

        int beginIndex = series.getBeginIndex();
        int endIndex = series.getEndIndex();
        
        // Adding the first begin index
        beginIndexes.add(beginIndex);

        // Building the first interval before next split
        ZonedDateTime beginInterval = series.getFirstTick().getEndTime();
        ZonedDateTime endInterval = beginInterval.plus(splitDuration);

        for (int i = beginIndex; i <= endIndex; i++) {
            // For each tick...
            ZonedDateTime tickTime = series.getTick(i).getEndTime();
            if (tickTime.isBefore(beginInterval) || !tickTime.isBefore(endInterval)) {
                // Tick out of the interval
                if (!endInterval.isAfter(tickTime)) {
                    // Tick after the interval
                    // --> Adding a new begin index
                    beginIndexes.add(i);
                }

                // Building the new interval before next split
                beginInterval = endInterval.isBefore(tickTime) ? tickTime : endInterval;
                endInterval = beginInterval.plus(splitDuration);
            }
        }
        return beginIndexes;
    }
public static List<Integer> getSplitBeginIndexes(TimeSeries series, Duration splitDuration) {
        ArrayList<Integer> beginIndexes = new ArrayList<>();

        int beginIndex = series.getBeginIndex();
        int endIndex = series.getEndIndex();
        
        
        beginIndexes.add(beginIndex);

        
        ZonedDateTime beginInterval = series.getFirstTick().getEndTime();
        ZonedDateTime endInterval = beginInterval.plus(splitDuration);

        for (int i = beginIndex; i <= endIndex; i++) {
            
            ZonedDateTime tickTime = series.getTick(i).getEndTime();
            if (tickTime.isBefore(beginInterval) || !tickTime.isBefore(endInterval)) {
                
                if (!endInterval.isAfter(tickTime)) {
                    
                    
                    beginIndexes.add(i);
                }

                
                beginInterval = endInterval.isBefore(tickTime) ? tickTime : endInterval;
                endInterval = beginInterval.plus(splitDuration);
            }
        }
        return beginIndexes;
    }
public static List < Integer > getSplitBeginIndexes ( TimeSeries series , Duration splitDuration ) { ArrayList < Integer > beginIndexes = new ArrayList <> ( ) ; int beginIndex = series . getBeginIndex ( ) ; int endIndex = series . getEndIndex ( ) ; // Adding the first begin index beginIndexes . add ( beginIndex ) ; // Building the first interval before next split ZonedDateTime beginInterval = series . getFirstTick ( ) . getEndTime ( ) ; ZonedDateTime endInterval = beginInterval . plus ( splitDuration ) ; for ( int i = beginIndex ; i <= endIndex ; i ++ ) { // For each tick... ZonedDateTime tickTime = series . getTick ( i ) . getEndTime ( ) ; if ( tickTime . isBefore ( beginInterval ) || ! tickTime . isBefore ( endInterval ) ) { // Tick out of the interval if ( ! endInterval . isAfter ( tickTime ) ) { // Tick after the interval // --> Adding a new begin index beginIndexes . add ( i ) ; } // Building the new interval before next split beginInterval = endInterval . isBefore ( tickTime ) ? tickTime : endInterval ; endInterval = beginInterval . plus ( splitDuration ) ; } } return beginIndexes ; }
Builds a list of split indexes from splitDuration.
@param series the time series to get split begin indexes of
@param splitDuration the duration between 2 splits
@return a list of begin indexes after split
Builds a list of split indexes from splitDuration .