/** * Creates a period from a set of field values. * * @param years amount of years in this period, which must be zero if unsupported * @param months amount of months in this period, which must be zero if unsupported * @param weeks amount of weeks in this period, which must be zero if unsupported * @param days amount of days in this period, which must be zero if unsupported * @param hours amount of hours in this period, which must be zero if unsupported * @param minutes amount of minutes in this period, which must be zero if unsupported * @param seconds amount of seconds in this period, which must be zero if unsupported * @param millis amount of milliseconds in this period, which must be zero if unsupported * @param type which set of fields this period supports * @throws IllegalArgumentException if period type is invalid * @throws IllegalArgumentException if an unsupported field's value is non-zero */ protected BasePeriod(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis, PeriodType type) { super(); type = checkPeriodType(type); iType = type; iValues = setPeriodInternal(years, months, weeks, days, hours, minutes, seconds, millis); // internal method }
/** * Creates a period from a set of field values. * * @param years amount of years in this period, which must be zero if unsupported * @param months amount of months in this period, which must be zero if unsupported * @param weeks amount of weeks in this period, which must be zero if unsupported * @param days amount of days in this period, which must be zero if unsupported * @param hours amount of hours in this period, which must be zero if unsupported * @param minutes amount of minutes in this period, which must be zero if unsupported * @param seconds amount of seconds in this period, which must be zero if unsupported * @param millis amount of milliseconds in this period, which must be zero if unsupported * @param type which set of fields this period supports * @throws IllegalArgumentException if period type is invalid * @throws IllegalArgumentException if an unsupported field's value is non-zero */ protected BasePeriod(int years, int months, int weeks, int days, int hours, int minutes, int seconds, int millis, PeriodType type) { super(); type = checkPeriodType(type); iType = type; iValues = setPeriodInternal(years, months, weeks, days, hours, minutes, seconds, millis); // internal method }
/** * Creates a period from the given interval endpoints. * * @param startInstant interval start, in milliseconds * @param endInstant interval end, in milliseconds * @param type which set of fields this period supports, null means standard * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period type is invalid */ protected BasePeriod(long startInstant, long endInstant, PeriodType type, Chronology chrono) { super(); type = checkPeriodType(type); chrono = DateTimeUtils.getChronology(chrono); iType = type; iValues = chrono.get(this, startInstant, endInstant); }
/** * Creates a period from the given interval endpoints. * * @param startInstant interval start, in milliseconds * @param endInstant interval end, in milliseconds * @param type which set of fields this period supports, null means standard * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period type is invalid */ protected BasePeriod(long startInstant, long endInstant, PeriodType type, Chronology chrono) { super(); type = checkPeriodType(type); chrono = DateTimeUtils.getChronology(chrono); iType = type; iValues = chrono.get(this, startInstant, endInstant); }
/** * Creates a period from the given millisecond duration, which is only really * suitable for durations less than one day. * <p> * Only fields that are precise will be used. * Thus the largest precise field may have a large value. * * @param duration the duration, in milliseconds * @param type which set of fields this period supports, null means standard * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period type is invalid */ protected BasePeriod(long duration, PeriodType type, Chronology chrono) { super(); type = checkPeriodType(type); chrono = DateTimeUtils.getChronology(chrono); iType = type; iValues = chrono.get(this, duration); }
/** * Creates a period from the given millisecond duration, which is only really * suitable for durations less than one day. * <p> * Only fields that are precise will be used. * Thus the largest precise field may have a large value. * * @param duration the duration, in milliseconds * @param type which set of fields this period supports, null means standard * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period type is invalid */ protected BasePeriod(long duration, PeriodType type, Chronology chrono) { super(); type = checkPeriodType(type); chrono = DateTimeUtils.getChronology(chrono); iType = type; iValues = chrono.get(this, duration); }
/** * 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 start point and duration. * * @param startInstant the interval start, null means now * @param duration the duration of the interval, null means zero-length * @param type which set of fields this period supports, null means standard */ protected BasePeriod(ReadableInstant startInstant, ReadableDuration duration, PeriodType type) { super(); type = checkPeriodType(type); long startMillis = DateTimeUtils.getInstantMillis(startInstant); long durationMillis = DateTimeUtils.getDurationMillis(duration); long endMillis = FieldUtils.safeAdd(startMillis, durationMillis); Chronology chrono = DateTimeUtils.getInstantChronology(startInstant); iType = type; iValues = chrono.get(this, startMillis, endMillis); }
/** * Creates a period from the given start point and duration. * * @param startInstant the interval start, null means now * @param duration the duration of the interval, null means zero-length * @param type which set of fields this period supports, null means standard */ protected BasePeriod(ReadableInstant startInstant, ReadableDuration duration, PeriodType type) { super(); type = checkPeriodType(type); long startMillis = DateTimeUtils.getInstantMillis(startInstant); long durationMillis = DateTimeUtils.getDurationMillis(duration); long endMillis = FieldUtils.safeAdd(startMillis, durationMillis); Chronology chrono = DateTimeUtils.getInstantChronology(startInstant); 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); }
/** * Creates a period from the given interval endpoints. * * @param startInstant interval start, null means now * @param endInstant interval end, null means now * @param type which set of fields this period supports, null means standard * @throws IllegalArgumentException if period type is invalid */ protected BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type) { super(); type = checkPeriodType(type); if (startInstant == null && endInstant == null) { iType = type; iValues = new int[size()]; } else { long startMillis = DateTimeUtils.getInstantMillis(startInstant); long endMillis = DateTimeUtils.getInstantMillis(endInstant); Chronology chrono = DateTimeUtils.getIntervalChronology(startInstant, endInstant); iType = type; iValues = chrono.get(this, startMillis, endMillis); } }
/** * Creates a period from the given interval endpoints. * * @param startInstant interval start, null means now * @param endInstant interval end, null means now * @param type which set of fields this period supports, null means standard * @throws IllegalArgumentException if period type is invalid */ protected BasePeriod(ReadableInstant startInstant, ReadableInstant endInstant, PeriodType type) { super(); type = checkPeriodType(type); if (startInstant == null && endInstant == null) { iType = type; iValues = new int[size()]; } else { long startMillis = DateTimeUtils.getInstantMillis(startInstant); long endMillis = DateTimeUtils.getInstantMillis(endInstant); Chronology chrono = DateTimeUtils.getIntervalChronology(startInstant, endInstant); iType = type; iValues = chrono.get(this, startMillis, endMillis); } }
type = checkPeriodType(type); long startMillis = ((BaseLocal) start).getLocalMillis(); long endMillis = ((BaseLocal) end).getLocalMillis(); throw new IllegalArgumentException("ReadablePartial objects must be contiguous"); iType = checkPeriodType(type); Chronology chrono = DateTimeUtils.getChronology(start.getChronology()).withUTC(); iValues = chrono.get(this, chrono.set(start, 0L), chrono.set(end, 0L));
type = checkPeriodType(type); long startMillis = ((BaseLocal) start).getLocalMillis(); long endMillis = ((BaseLocal) end).getLocalMillis(); throw new IllegalArgumentException("ReadablePartial objects must be contiguous"); iType = checkPeriodType(type); Chronology chrono = DateTimeUtils.getChronology(start.getChronology()).withUTC(); iValues = chrono.get(this, chrono.set(start, 0L), chrono.set(end, 0L));
/** * Creates a new period based on another using the {@link ConverterManager}. * * @param period the period to convert * @param type which set of fields this period supports, null means use type from object * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period is invalid * @throws IllegalArgumentException if an unsupported field's value is non-zero */ protected BasePeriod(Object period, PeriodType type, Chronology chrono) { super(); PeriodConverter converter = ConverterManager.getInstance().getPeriodConverter(period); type = (type == null ? converter.getPeriodType(period) : type); type = checkPeriodType(type); iType = type; if (this instanceof ReadWritablePeriod) { iValues = new int[size()]; chrono = DateTimeUtils.getChronology(chrono); converter.setInto((ReadWritablePeriod) this, period, chrono); } else { iValues = new MutablePeriod(period, type, chrono).getValues(); } }
/** * Creates a new period based on another using the {@link ConverterManager}. * * @param period the period to convert * @param type which set of fields this period supports, null means use type from object * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period is invalid * @throws IllegalArgumentException if an unsupported field's value is non-zero */ protected BasePeriod(Object period, PeriodType type, Chronology chrono) { super(); PeriodConverter converter = ConverterManager.getInstance().getPeriodConverter(period); type = (type == null ? converter.getPeriodType(period) : type); type = checkPeriodType(type); iType = type; if (this instanceof ReadWritablePeriod) { iValues = new int[size()]; chrono = DateTimeUtils.getChronology(chrono); converter.setInto((ReadWritablePeriod) this, period, chrono); } else { iValues = new MutablePeriod(period, type, chrono).getValues(); } }
/** * Creates a period from the given interval endpoints. * * @param startInstant interval start, in milliseconds * @param endInstant interval end, in milliseconds * @param type which set of fields this period supports, null means standard * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period type is invalid */ protected BasePeriod(long startInstant, long endInstant, PeriodType type, Chronology chrono) { super(); type = checkPeriodType(type); chrono = DateTimeUtils.getChronology(chrono); iType = type; iValues = chrono.get(this, startInstant, endInstant); }
/** * Creates a period from the given millisecond duration, which is only really * suitable for durations less than one day. * <p> * Only fields that are precise will be used. * Thus the largest precise field may have a large value. * * @param duration the duration, in milliseconds * @param type which set of fields this period supports, null means standard * @param chrono the chronology to use, null means ISO default * @throws IllegalArgumentException if period type is invalid */ protected BasePeriod(long duration, PeriodType type, Chronology chrono) { super(); type = checkPeriodType(type); chrono = DateTimeUtils.getChronology(chrono); iType = type; iValues = chrono.get(this, duration); }
/** * Creates a period from the given start point and duration. * * @param startInstant the interval start, null means now * @param duration the duration of the interval, null means zero-length * @param type which set of fields this period supports, null means standard */ protected BasePeriod(ReadableInstant startInstant, ReadableDuration duration, PeriodType type) { super(); type = checkPeriodType(type); long startMillis = DateTimeUtils.getInstantMillis(startInstant); long durationMillis = DateTimeUtils.getDurationMillis(duration); long endMillis = FieldUtils.safeAdd(startMillis, durationMillis); Chronology chrono = DateTimeUtils.getInstantChronology(startInstant); 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); }