public static Integer durationSeconds ( String duration ) { BigDecimal ns = durationNs ( duration ) ; if ( ns == null ) { return null ; } BigDecimal sec = ns . divide ( new BigDecimal ( 1_000_000_000 ) ) ; if ( sec . compareTo ( new BigDecimal ( Integer . MAX_VALUE ) ) > 0 ) { throw new IllegalArgumentException ( "Integer Overflow" ) ; } return sec . intValue ( ) ; }
Parses a duration string anr returns its value in seconds .