static String constructIndexName ( String indexName , int indexRollsPerDay , Date date ) { if ( indexRollsPerDay > 0 ) { ZonedDateTime zdt = ZonedDateTime . ofInstant ( date . toInstant ( ) , ZoneId . of ( "UTC" ) ) ; int minutesPerRoll = 1440 / indexRollsPerDay ; int minutesElapsedSinceStartOfDay = zdt . getHour ( ) * 60 + zdt . getMinute ( ) ; int nthRoll = minutesElapsedSinceStartOfDay / minutesPerRoll ; String retval = String . format ( "%s-%s.%04d" , indexName , zdt . format ( DateTimeFormatter . ofPattern ( "yyyy-MM-dd" ) ) , nthRoll ) ; logger . debug ( "constructIndexName from rolls per day = {} gives: {}" , indexRollsPerDay , retval ) ; return retval ; } else { return indexName ; } }
methods below are package scoped to facilitate unit testing