@Test public void compoundValues() { assertEquals( 65000L, TimeUtils.millisFromDuration( "1m,5s" ) ); assertEquals( 1293484000L, TimeUtils.millisFromDuration( "14d,23h,18m,4s" ) ); assertEquals( 1293484000L, TimeUtils.millisFromDuration( "18m,23h,4s,14d" ) ); assertEquals( 8005L, TimeUtils.millisFromDuration( "8s,5S" ) ); assertEquals( 16137L, TimeUtils.millisFromDuration( "15s,1137" ) ); }
public static long millisFromDuration( String durationStr ) { long total = 0; MultiplierToken mt; long dur; for ( String val : Splitter.on( ',' ).trimResults().omitEmptyStrings().split( durationStr ) ) { dur = Long.parseLong( CharMatcher.DIGIT.retainFrom( val ) ); mt = MultiplierToken.from( val.charAt( val.length() - 1 ) ); total += ( mt.multiplier * dur ); } return total; }
TimeUtils { public static long millisFromDuration( String durationStr ) { long total = 0; MultiplierToken mt; long dur; for ( String val : Splitter.on( ',' ).trimResults().omitEmptyStrings().split( durationStr ) ) { dur = Long.parseLong( CharMatcher.DIGIT.retainFrom( val ) ); mt = MultiplierToken.from( val.charAt( val.length() - 1 ) ); total += ( mt.multiplier * dur ); } return total; } }
TimeUtils { public static long millisFromDuration( String durationStr ) { long total = 0; MultiplierToken mt; long dur; for ( String val : Splitter.on( ',' ).trimResults().omitEmptyStrings().split( durationStr ) ) { dur = Long.parseLong( CharMatcher.DIGIT.retainFrom( val ) ); mt = MultiplierToken.from( val.charAt( val.length() - 1 ) ); total += ( mt.multiplier * dur ); } return total; }  }
TimeUtils { public static long millisFromDuration( String durationStr ) { long total = 0; MultiplierToken mt; long dur; for ( String val : Splitter.on( ',' ).trimResults().omitEmptyStrings().split( durationStr ) ) { dur = Long.parseLong( CharMatcher.DIGIT.retainFrom( val ) ); mt = MultiplierToken.from( val.charAt( val.length() - 1 ) ); total += ( mt.multiplier * dur ); } return total; }  static long millisFromDuration( String durationStr ); }
TimeUtils { public static long millisFromDuration( String durationStr ) { long total = 0; MultiplierToken mt; long dur; for ( String val : Splitter.on( ',' ).trimResults().omitEmptyStrings().split( durationStr ) ) { dur = Long.parseLong( CharMatcher.DIGIT.retainFrom( val ) ); mt = MultiplierToken.from( val.charAt( val.length() - 1 ) ); total += ( mt.multiplier * dur ); } return total; }  static long millisFromDuration( String durationStr );  }