@Test public void fromSingleValues() { assertEquals( 172800000L, TimeUtils.millisFromDuration( "2d" ) ); assertEquals( 420000L, TimeUtils.millisFromDuration( "7m" ) ); assertEquals( 90000L, TimeUtils.millisFromDuration( "90s" ) ); assertEquals( TimeUtils.millisFromDuration( "1d" ), TimeUtils.millisFromDuration( "24h" ) ); assertEquals( 250L, TimeUtils.millisFromDuration( "250S" ) ); }
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 );  }