/** * Get the millisecond duration of this field from its value. * * @param value the value of the field, which may be negative * @param instant ignored * @return the milliseconds that the field represents, which may be * negative */ public long getMillis(long value, long instant) { return FieldUtils.safeMultiply(value, iUnitMillis); }
/** * Multiply two values to return an int throwing an exception if overflow occurs. * * @param val1 the first value * @param val2 the second value * @return the new total * @throws ArithmeticException if the value is too big or too small */ public static int safeMultiplyToInt(long val1, long val2) { long val = FieldUtils.safeMultiply(val1, val2); return FieldUtils.safeToInt(val); }
/** * Get the millisecond duration of this field from its value, which is * approximate if this field is imprecise. * * @param value the value of the field, which may be negative * @return the milliseconds that the field represents, which may be * negative */ public long getMillis(long value) { return FieldUtils.safeMultiply(value, getUnitMillis()); }
/** * Obtains an {@code Instant} set to the seconds from 1970-01-01T00:00:00Z. * * @param epochSecond the seconds from 1970-01-01T00:00:00Z * @throws ArithmeticException if the new instant exceeds the capacity of a long * @since 2.10 */ public static Instant ofEpochSecond(long epochSecond) { return new Instant(FieldUtils.safeMultiply(epochSecond, 1000)); }
/** * Obtains an {@code Instant} set to the seconds from 1970-01-01T00:00:00Z. * * @param epochSecond the seconds from 1970-01-01T00:00:00Z * @throws ArithmeticException if the new instant exceeds the capacity of a long * @since 2.10 */ public static Instant ofEpochSecond(long epochSecond) { return new Instant(FieldUtils.safeMultiply(epochSecond, 1000)); }
/** * Multiply two values to return an int throwing an exception if overflow occurs. * * @param val1 the first value * @param val2 the second value * @return the new total * @throws ArithmeticException if the value is too big or too small */ public static int safeMultiplyToInt(long val1, long val2) { long val = FieldUtils.safeMultiply(val1, val2); return FieldUtils.safeToInt(val); }
/** * Returns a new instance with the hours multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Hours multipliedBy(int scalar) { return Hours.hours(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the weeks multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Weeks multipliedBy(int scalar) { return Weeks.weeks(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the days multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Days multipliedBy(int scalar) { return Days.days(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the months multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Months multipliedBy(int scalar) { return Months.months(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the minutes multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Minutes multipliedBy(int scalar) { return Minutes.minutes(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the seconds multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Seconds multipliedBy(int scalar) { return Seconds.seconds(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the years multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Years multipliedBy(int scalar) { return Years.years(FieldUtils.safeMultiply(getValue(), scalar)); }
public long getMillis(long value) { long scaled = FieldUtils.safeMultiply(value, iScalar); return getWrappedField().getMillis(scaled); }
public long getMillis(long value, long instant) { long scaled = FieldUtils.safeMultiply(value, iScalar); return getWrappedField().getMillis(scaled, instant); }
/** * Returns a new instance with the seconds multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Seconds multipliedBy(int scalar) { return Seconds.seconds(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the years multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Years multipliedBy(int scalar) { return Years.years(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the hours multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Hours multipliedBy(int scalar) { return Hours.hours(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the months multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Months multipliedBy(int scalar) { return Months.months(FieldUtils.safeMultiply(getValue(), scalar)); }
/** * Returns a new instance with the weeks multiplied by the specified scalar. * <p> * This instance is immutable and unaffected by this method call. * * @param scalar the amount to multiply by, may be negative * @return the new period multiplied by the specified scalar * @throws ArithmeticException if the result overflows an int */ public Weeks multipliedBy(int scalar) { return Weeks.weeks(FieldUtils.safeMultiply(getValue(), scalar)); }