List of usage examples for org.joda.time ReadableDuration getMillis
long getMillis();
From source file:ch.oakmountain.tpa.solver.PeriodicalTimeFrame.java
License:Apache License
/** * Returns a copy of this datetime with the specified duration added. * <p/>//from w ww . j a v a 2 s . com * If the addition is zero, then <code>this</code> is returned. * * @param durationToAdd the duration to add to this one, null means zero * @param scalar the amount of times to add, such as -1 to subtract once * @return a copy of this datetime with the duration added * @throws ArithmeticException if the result exceeds the internal capacity */ public PeriodicalTimeFrame withDurationAdded(ReadableDuration durationToAdd, int scalar) { if (durationToAdd == null || scalar == 0) { return this; } long instant = getChronology().add(getLocalMillis(), durationToAdd.getMillis(), scalar); return withLocalMillis(instant); }
From source file:com.almende.timecontrol.time.TimeSpan.java
License:Apache License
/** * {@link TimeSpan} static factory method * /*from w ww. j a v a 2s.com*/ * @param value */ public static TimeSpan valueOf(final ReadableDuration value) { return new TimeSpan(BigDecimal.valueOf(value.getMillis()), TimeControl.MILLIS); }
From source file:com.example.time.testing.FakeClock.java
License:Open Source License
/** * Increments the clock time by the given duration. * * @param duration the duration to increment the clock time by * @return this/*from w w w .java 2s. co m*/ */ public FakeClock incrementTime(ReadableDuration duration) { incrementTime(duration.getMillis()); return this; }
From source file:com.example.time.testing.FakeClock.java
License:Open Source License
/** * Decrements the clock time by the given duration. * * @param duration the duration to decrement the clock time by * @return this/* w w w. j a v a 2 s . c o m*/ */ public FakeClock decrementTime(ReadableDuration duration) { incrementTime(-duration.getMillis()); return this; }
From source file:com.example.time.testing.FakeClock.java
License:Open Source License
/** * Sets the increment applied to the clock whenever it is queried. * The increment is zero by default: the clock is left unchanged when queried. * * @param autoIncrementStep the new auto increment duration * @return this// ww w . j a v a 2s . c o m */ public FakeClock setAutoIncrementStep(ReadableDuration autoIncrementStep) { setAutoIncrementStep(autoIncrementStep.getMillis()); return this; }
From source file:com.facebook.stats.AbstractCompositeCounter.java
License:Apache License
public AbstractCompositeCounter(ReadableDuration maxLength) { this(maxLength, new Duration(maxLength.getMillis() / 10)); }
From source file:com.google.cloud.dataflow.sdk.coders.DurationCoder.java
License:Apache License
private Long toLong(ReadableDuration value) { return value.getMillis(); }
From source file:com.google.cloud.dataflow.sdk.util.TimeUtil.java
License:Apache License
/** * Converts a {@link ReadableDuration} into a Dataflow API duration string. *///from w w w. j av a 2s. com public static String toCloudDuration(ReadableDuration duration) { // Note that since Joda objects use millisecond resolution, we always // produce either no fractional seconds or fractional seconds with // millisecond resolution. long millis = duration.getMillis(); long seconds = millis / 1000; millis = millis % 1000; if (millis == 0) { return String.format("%ds", seconds); } else { return String.format("%d.%03ds", seconds, millis); } }
From source file:google.registry.testing.FakeClock.java
License:Open Source License
/** Advances clock by some duration. */ public void advanceBy(ReadableDuration duration) { currentTimeMillis.addAndGet(duration.getMillis()); }
From source file:google.registry.testing.FakeSleeper.java
License:Open Source License
@Override public void sleep(ReadableDuration duration) throws InterruptedException { checkArgument(duration.getMillis() >= 0); if (Thread.interrupted()) { throw new InterruptedException(); }/* www .j av a 2 s . c o m*/ clock.advanceBy(duration); }