/** * Expresses the provided duration in the unit provided. Note that the timespan returned * represent only the truncated version of the duration: if duration is 1002ms and timeunit * is seconds, then the timespan returned is 1 second... leaving behind 2ms. * * @return the timespan */ private static Timespan truncateDurationToUnit(long durationInMillis, TimeUnit timeUnit) { Timespan res; if (durationInMillis >= timeUnit.getMillisecondsCount()) { res = new Timespan(durationInMillis / timeUnit.getMillisecondsCount(), timeUnit); } else { res = ZERO_TIMESPANS.get(timeUnit); } return res; }
/** * Expresses the provided duration in the unit provided. Note that the timespan returned * represent only the truncated version of the duration: if duration is 1002ms and timeunit * is seconds, then the timespan returned is 1 second... leaving behind 2ms. * * @return the timespan */ private static Timespan truncateDurationToUnit(long durationInMillis, TimeUnit timeUnit) { Timespan res; if (durationInMillis >= timeUnit.getMillisecondsCount()) { res = new Timespan(durationInMillis / timeUnit.getMillisecondsCount(), timeUnit); } else { res = ZERO_TIMESPANS.get(timeUnit); } return res; }
/** * @return the duration of this timespan in milliseconds */ public long getDurationInMilliseconds() { // 100% equivalent to getDuration(TimeUnit.MILLISECOND) but faster! return getDuration() * getTimeUnit().getMillisecondsCount(); }
/** * @return the duration of this timespan in milliseconds */ public long getDurationInMilliseconds() { // 100% equivalent to getDuration(TimeUnit.MILLISECOND) but faster! return getDuration() * getTimeUnit().getMillisecondsCount(); }