public static int [ ] sliceByTime ( CSTable table , int timeCol , Date start , Date end ) { if ( end . before ( start ) ) { throw new IllegalArgumentException ( "end<start" ) ; } if ( timeCol < 0 ) { throw new IllegalArgumentException ( "timeCol :" + timeCol ) ; } int s = - 1 ; int e = - 1 ; int i = - 1 ; for ( String [ ] col : table . rows ( ) ) { i ++ ; Date d = Conversions . convert ( col [ timeCol ] , Date . class ) ; if ( s == - 1 && ( start . before ( d ) || start . equals ( d ) ) ) { s = i ; } if ( e == - 1 && ( end . before ( d ) || end . equals ( d ) ) ) { e = i ; break ; } } return new int [ ] { s , e } ; }
Get a slice of rows out of the table matching the time window