/** * Creates a duration from the given interval endpoints. * * @param startInstant interval start, in milliseconds * @param endInstant interval end, in milliseconds * @throws ArithmeticException if the duration exceeds a 64-bit long */ protected BaseDuration(long startInstant, long endInstant) { super(); iMillis = FieldUtils.safeSubtract(endInstant, startInstant); }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { return FieldUtils.safeSubtract(minuendInstant, subtrahendInstant); }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { long difference = FieldUtils.safeSubtract(minuendInstant, subtrahendInstant); return difference / iUnitMillis; }
/** * Creates a duration from the given interval endpoints. * * @param startInstant interval start, in milliseconds * @param endInstant interval end, in milliseconds * @throws ArithmeticException if the duration exceeds a 64-bit long */ protected BaseDuration(long startInstant, long endInstant) { super(); iMillis = FieldUtils.safeSubtract(endInstant, startInstant); }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { long difference = FieldUtils.safeSubtract(minuendInstant, subtrahendInstant); return difference / iUnitMillis; }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { return FieldUtils.safeSubtract(minuendInstant, subtrahendInstant); }
public int getDifference(long minuendInstant, long subtrahendInstant) { return FieldUtils.safeToInt(FieldUtils.safeSubtract(minuendInstant, subtrahendInstant)); }
public int getDifference(long minuendInstant, long subtrahendInstant) { return FieldUtils.safeToInt(FieldUtils.safeSubtract(minuendInstant, subtrahendInstant)); }
/** * Gets the duration of this time interval in milliseconds. * <p> * The duration is equal to the end millis minus the start millis. * * @return the duration of the time interval in milliseconds * @throws ArithmeticException if the duration exceeds the capacity of a long */ public long toDurationMillis() { return FieldUtils.safeSubtract(getEndMillis(), getStartMillis()); }
/** * Gets the duration of this time interval in milliseconds. * <p> * The duration is equal to the end millis minus the start millis. * * @return the duration of the time interval in milliseconds * @throws ArithmeticException if the duration exceeds the capacity of a long */ public long toDurationMillis() { return FieldUtils.safeSubtract(getEndMillis(), getStartMillis()); }
/** * Creates a duration from the given interval endpoints. * * @param start interval start, null means now * @param end interval end, null means now * @throws ArithmeticException if the duration exceeds a 64-bit long */ protected BaseDuration(ReadableInstant start, ReadableInstant end) { super(); if (start == end) { iMillis = 0L; } else { long startMillis = DateTimeUtils.getInstantMillis(start); long endMillis = DateTimeUtils.getInstantMillis(end); iMillis = FieldUtils.safeSubtract(endMillis, startMillis); } }
/** * Creates a duration from the given interval endpoints. * * @param start interval start, null means now * @param end interval end, null means now * @throws ArithmeticException if the duration exceeds a 64-bit long */ protected BaseDuration(ReadableInstant start, ReadableInstant end) { super(); if (start == end) { iMillis = 0L; } else { long startMillis = DateTimeUtils.getInstantMillis(start); long endMillis = DateTimeUtils.getInstantMillis(end); iMillis = FieldUtils.safeSubtract(endMillis, startMillis); } }
/** * Creates a period from the given duration and end point. * * @param duration the duration of the interval, null means zero-length * @param endInstant the interval end, null means now * @param type which set of fields this period supports, null means standard */ protected BasePeriod(ReadableDuration duration, ReadableInstant endInstant, PeriodType type) { super(); type = checkPeriodType(type); long durationMillis = DateTimeUtils.getDurationMillis(duration); long endMillis = DateTimeUtils.getInstantMillis(endInstant); long startMillis = FieldUtils.safeSubtract(endMillis, durationMillis); Chronology chrono = DateTimeUtils.getInstantChronology(endInstant); iType = type; iValues = chrono.get(this, startMillis, endMillis); }
/** * Creates a period from the given duration and end point. * * @param duration the duration of the interval, null means zero-length * @param endInstant the interval end, null means now * @param type which set of fields this period supports, null means standard */ protected BasePeriod(ReadableDuration duration, ReadableInstant endInstant, PeriodType type) { super(); type = checkPeriodType(type); long durationMillis = DateTimeUtils.getDurationMillis(duration); long endMillis = DateTimeUtils.getInstantMillis(endInstant); long startMillis = FieldUtils.safeSubtract(endMillis, durationMillis); Chronology chrono = DateTimeUtils.getInstantChronology(endInstant); iType = type; iValues = chrono.get(this, startMillis, endMillis); }
/** * Set values which may be out of bounds by adding the difference between * the new value and the current value. */ public long set(long instant, int value) { // lenient needs to handle time zone chronologies // so we do the calculation using local milliseconds long localInstant = iBase.getZone().convertUTCToLocal(instant); long difference = FieldUtils.safeSubtract(value, get(instant)); localInstant = getType().getField(iBase.withUTC()).add(localInstant, difference); return iBase.getZone().convertLocalToUTC(localInstant, false, instant); } }
/** * Set values which may be out of bounds by adding the difference between * the new value and the current value. */ public long set(long instant, int value) { // lenient needs to handle time zone chronologies // so we do the calculation using local milliseconds long localInstant = iBase.getZone().convertUTCToLocal(instant); long difference = FieldUtils.safeSubtract(value, get(instant)); localInstant = getType().getField(iBase.withUTC()).add(localInstant, difference); return iBase.getZone().convertLocalToUTC(localInstant, false, instant); } }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { long difference = FieldUtils.safeSubtract(minuendInstant, subtrahendInstant); return difference / iUnitMillis; }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { return FieldUtils.safeSubtract(minuendInstant, subtrahendInstant); }
public int getDifference(long minuendInstant, long subtrahendInstant) { return FieldUtils.safeToInt(FieldUtils.safeSubtract(minuendInstant, subtrahendInstant)); }
/** * Set values which may be out of bounds by adding the difference between * the new value and the current value. */ public long set(long instant, int value) { // lenient needs to handle time zone chronologies // so we do the calculation using local milliseconds long localInstant = iBase.getZone().convertUTCToLocal(instant); long difference = FieldUtils.safeSubtract(value, get(instant)); localInstant = getType().getField(iBase.withUTC()).add(localInstant, difference); return iBase.getZone().convertLocalToUTC(localInstant, false, instant); } }