List of usage examples for org.joda.time.field FieldUtils safeMultiplyToInt
public static int safeMultiplyToInt(long val1, long val2)
From source file:com.facebook.util.TimeInterval.java
License:Apache License
/** * Adds supplied multiples of this interval to the supplied instant. * * @param instant the instant that needs to be added to. * @param multiple the multiple value//w w w . j ava 2s . c om * @throws IllegalArgumentException if multiple is less than one. * @throws UnsupportedOperationException if the function is invoked on an {@link #INFINITE} * object * */ public DateTime plus(DateTime instant, int multiple) { if (this == INFINITE) { throw new IllegalStateException("plus() function is not supported on an infinite TimeInterval"); } else if (this == ZERO) { return instant; } validateMultiple(multiple); if (type == null) { return instant.plus(multiple * getLength()); } else { return instant.plus(type.toPeriod(FieldUtils.safeMultiplyToInt(multiple, getLength()))); } }
From source file:com.facebook.util.TimeInterval.java
License:Apache License
/** * Subtracts the supplied multiples of this interval from the supplied instant. If the * TimeInterval is {@link #INFINITE} the epoch in the timezone of {@code instant} is returned * * @param instant the instant to subtract from * @param multiple the multiple value/* w ww. j av a 2 s.c o m*/ * @throws IllegalArgumentException if multiple is less than one. */ public DateTime minus(DateTime instant, int multiple) { if (this == INFINITE) { throw new IllegalStateException("minus() function is not supported on an infinite TimeInterval"); } else if (this == ZERO) { return instant; } validateMultiple(multiple); if (type == null) { return instant.minus(multiple * getLength()); } else { return instant.minus(type.toPeriod(FieldUtils.safeMultiplyToInt(multiple, getLength()))); } }