Obtains an instance of {@code ChronoPeriodImpl} from a temporal amount.

@param amount  the temporal amount to convert, not null
@return the period, not null
348784
private ChronoPeriodImpl validateAmount(TemporalAmount amount) {
        Objects.requireNonNull(amount, "amount");
        if (amount instanceof ChronoPeriodImpl == false) {
            throw new DateTimeException("Unable to obtain ChronoPeriod from TemporalAmount: " + amount.getClass());
        }
        ChronoPeriodImpl period = (ChronoPeriodImpl) amount;
        if (chrono.equals(period.getChronology()) == false) {
            throw new ClassCastException("Chronology mismatch, expected: " + chrono.getId() + ", actual: " + period.getChronology().getId());
        }
        return period;
    }
24461
public D plus(D duration) {

        if (duration.isEmpty()) {
            return this.self();
        }

        long value = this.amount;
        return this.with(MathUtils.safeCast(value + duration.getAmount()));

    }
1368732
@Override
    public MonetaryAmount apply(MonetaryAmount amount) {
        requireNonNull(amount, "Amount required.");
        NumberValue num = amount.getNumber();
        BigDecimal one = ONE.setScale(num.getScale() < 5 ? 5 : num.getScale(), HALF_EVEN);
        BigDecimal reciprocal = one.divide(num.numberValue(BigDecimal.class), HALF_EVEN);
        return amount.getFactory().setNumber(reciprocal).create();
    }
270616
public static Date addMinute(String date, int amount) throws ParseException {
        return add(date, Calendar.MINUTE, amount);
    }
642410
public double getAndSet(double amount) {
    long v = value.getAndSet(Double.doubleToLongBits(amount));
    return Double.longBitsToDouble(v);
  }
990421
@Override
        public HebrewTime addTo(
            HebrewTime context,
            long amount
        ) {

            if (amount == 0) {
                return context;
            }

            int h;
            int p;

            switch (this.unit) {
                case HOURS:
                    h = MathUtils.floorModulo(MathUtils.safeAdd(context.hour23, amount), 24);
                    p = context.part;
                    break;
                case HALAKIM:
                    long sum = MathUtils.safeAdd(context.part, amount);
                    p = MathUtils.floorModulo(sum, PARTS_IN_HOUR);
                    long overflow = MathUtils.floorDivide(sum, PARTS_IN_HOUR);
                    h = MathUtils.floorModulo(MathUtils.safeAdd(context.hour23, overflow), 24);
                    break;
                default:
                    throw new UnsupportedOperationException(this.unit.name());
            }

            return new HebrewTime(h, p);

        }
161071
public static <D extends Comparable> DateTimeExpression<D> dateadd(DatePart unit, DateTimeExpression<D> date, int amount) {
        return Expressions.dateTimeOperation(date.getType(), DATE_ADD_OPS.get(unit), date, ConstantImpl.create(amount));
    }
394609
@Override
	public double getLiborPeriod(int timeIndex) {
		if(timeIndex >= liborPeriodDiscretization.getNumberOfTimes()) {
			throw new ArrayIndexOutOfBoundsException("Index for LIBOR period discretization out of bounds.");
		}
		return liborPeriodDiscretization.getTime(timeIndex);
	}
301699
@Override
    public MonetaryAmount apply(MonetaryAmount amount) {
        return amount.getFactory().setCurrency(amount.getCurrency()).setNumber(
                amount.getNumber().numberValue(BigDecimal.class)
                        .setScale(this.context.getInt(SCALE_KEY), this.context.get(RoundingMode.class))).create();
    }
932840
public int[] get(ReadablePeriod period, long duration) {
        int size = period.size();
        int[] values = new int[size];
        if (duration != 0) {
            long current = 0;
            for (int i = 0; i < size; i++) {
                DurationField field = period.getFieldType(i).getField(this);
                if (field.isPrecise()) {
                    int value = field.getDifference(duration, current);
                    current = field.add(current, value);
                    values[i] = value;
                }
            }
        }
        return values;
    }
688341
@Override
	public MonetaryAmount apply(MonetaryAmount amount) {
		Objects.requireNonNull(amount, "Amount required.");
		return amount.multiply(permilValue);
	}
1373591
private static long getPeriodBoundary(long timestamp, RateBucketPeriod period) {
        Calendar lastCal = Calendar.getInstance();
        lastCal.setTimeInMillis(timestamp);
        switch (period) {
        case Second:
            lastCal.set(Calendar.MILLISECOND, 0);
            lastCal.add(Calendar.SECOND, 1);
            return lastCal.getTimeInMillis();
        case Minute:
            lastCal.set(Calendar.MILLISECOND, 0);
            lastCal.set(Calendar.SECOND, 0);
            lastCal.add(Calendar.MINUTE, 1);
            return lastCal.getTimeInMillis();
        case Hour:
            lastCal.set(Calendar.MILLISECOND, 0);
            lastCal.set(Calendar.SECOND, 0);
            lastCal.set(Calendar.MINUTE, 0);
            lastCal.add(Calendar.HOUR_OF_DAY, 1);
            return lastCal.getTimeInMillis();
        case Day:
            lastCal.set(Calendar.MILLISECOND, 0);
            lastCal.set(Calendar.SECOND, 0);
            lastCal.set(Calendar.MINUTE, 0);
            lastCal.set(Calendar.HOUR_OF_DAY, 0);
            lastCal.add(Calendar.DAY_OF_YEAR, 1);
            return lastCal.getTimeInMillis();
        case Month:
            lastCal.set(Calendar.MILLISECOND, 0);
            lastCal.set(Calendar.SECOND, 0);
            lastCal.set(Calendar.MINUTE, 0);
            lastCal.set(Calendar.HOUR_OF_DAY, 0);
            lastCal.set(Calendar.DAY_OF_MONTH, 1);
            lastCal.add(Calendar.MONTH, 1);
            return lastCal.getTimeInMillis();
        case Year:
            lastCal.set(Calendar.MILLISECOND, 0);
            lastCal.set(Calendar.SECOND, 0);
            lastCal.set(Calendar.MINUTE, 0);
            lastCal.set(Calendar.HOUR_OF_DAY, 0);
            lastCal.set(Calendar.DAY_OF_YEAR, 1);
            lastCal.add(Calendar.YEAR, 1);
            return lastCal.getTimeInMillis();
        }
        return Long.MAX_VALUE;
    }
383134
public static Date addDay(Date date, int amount) {
        return add(date, Calendar.DATE, amount);
    }
548780
public long get(final TimeUnit toUnit)
	{
		if (this.unit == toUnit)
			return period;
		else
			return toUnit.convert(period, this.unit);
	}
764971
public static Date add(DateUnit dateUnit, int amount, Date date) {
        return Date.from(date.toInstant().plus(amount, create(dateUnit)));
    }
434525
public static java.sql.Time rollTime(java.util.Date startDate, int period, int amount) {
        GregorianCalendar gc = new GregorianCalendar();
        gc.setTime(startDate);
        gc.add(period, amount);
        return new java.sql.Time(gc.getTime().getTime());
    }
1364495
public ClockInterval move(
        long amount,
        ClockUnit unit
    ) {

        if (amount == 0) {
            return this;
        }

        Boundary<PlainTime> s;
        Boundary<PlainTime> e;

        if (this.getStart().isInfinite()) {
            s = Boundary.infinitePast();
        } else {
            s =
                Boundary.of(
                    this.getStart().getEdge(),
                    this.getStart().getTemporal().plus(amount, unit));
        }

        if (this.getEnd().isInfinite()) {
            e = Boundary.infiniteFuture();
        } else {
            e =
                Boundary.of(
                    this.getEnd().getEdge(),
                    this.getEnd().getTemporal().plus(amount, unit));
        }

        return new ClockInterval(s, e);

    }