public static StringBuilder durationConfigString ( Duration duration ) { Duration remainder = duration ; long days = remainder . getStandardDays ( ) ; remainder = remainder . minus ( Duration . standardDays ( days ) ) ; long hours = remainder . getStandardHours ( ) ; remainder = remainder . minus ( Duration . standardHours ( hours ) ) ; long minutes = remainder . getStandardMinutes ( ) ; remainder = remainder . minus ( Duration . standardMinutes ( minutes ) ) ; long seconds = remainder . getStandardSeconds ( ) ; remainder = remainder . minus ( Duration . standardSeconds ( seconds ) ) ; if ( ! remainder . isEqual ( Duration . ZERO ) ) Logger . getLogger ( ConfigSupport . class . getName ( ) ) . log ( Level . WARNING , "Duration is more precise than configuration will handle: {0}, dropping remainder: {1}" , new Object [ ] { duration , remainder } ) ; StringBuilder result = new StringBuilder ( ) ; if ( days != 0 ) { if ( result . length ( ) != 0 ) result . append ( ' ' ) ; result . append ( days ) . append ( ' ' ) ; } if ( hours != 0 ) { if ( result . length ( ) != 0 ) result . append ( ' ' ) ; result . append ( hours ) . append ( ' ' ) ; } if ( minutes != 0 ) { if ( result . length ( ) != 0 ) result . append ( ' ' ) ; result . append ( minutes ) . append ( ' ' ) ; } if ( result . length ( ) == 0 || seconds != 0 ) { if ( result . length ( ) != 0 ) result . append ( ' ' ) ; result . append ( seconds ) . append ( ' ' ) ; } return result ; }
Convert duration to an representation accepted by Configuration parser .