Refine search
@Override public DateTimeField getField(Chronology chronology) { return new OffsetDateTimeField(new DividedDateTimeField(new OffsetDateTimeField(chronology.monthOfYear(), -1), QUARTER_OF_YEAR, 3), 1); }
public long roundFloor(long instant) { DateTimeField field = getWrappedField(); return field.roundFloor(field.set(instant, get(instant) * iDivisor)); }
/** * Set the specified amount of scaled units to the specified time instant. * * @param instant the time instant in millis to update. * @param value value of scaled units to set. * @return the updated time instant. * @throws IllegalArgumentException if value is too large or too small. */ public long set(long instant, int value) { FieldUtils.verifyValueBounds(this, value, iMin, iMax); int remainder = getRemainder(getWrappedField().get(instant)); return getWrappedField().set(instant, value * iDivisor + remainder); }
public long remainder(long instant) { return set(instant, get(getWrappedField().remainder(instant))); }
/** * Add to the scaled component of the specified time instant, * wrapping around within that component if necessary. * * @param instant the time instant in millis to update. * @param amount the amount of scaled units to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { return set(instant, FieldUtils.getWrappedValue(get(instant), amount, iMin, iMax)); }
fields.year = new OffsetDateTimeField( new SkipUndoDateTimeField(this, field), BUDDHIST_OFFSET); fields.weekyear = new OffsetDateTimeField( new SkipUndoDateTimeField(this, field), BUDDHIST_OFFSET); field = new OffsetDateTimeField(fields.yearOfEra, 99); fields.centuryOfEra = new DividedDateTimeField( field, fields.eras, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField();
protected void assemble(Fields fields) { if (getBase().getZone() == DateTimeZone.UTC) { // Use zero based century and year of century. fields.centuryOfEra = new DividedDateTimeField( ISOYearOfEraDateTimeField.INSTANCE, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField(); fields.yearOfCentury = new RemainderDateTimeField( (DividedDateTimeField) fields.centuryOfEra, DateTimeFieldType.yearOfCentury()); fields.weekyearOfCentury = new RemainderDateTimeField( (DividedDateTimeField) fields.centuryOfEra, fields.weekyears, DateTimeFieldType.weekyearOfCentury()); } }
/** * Add the specified amount of scaled units to the specified time * instant. The amount added may be negative. * * @param instant the time instant in millis to update. * @param amount the amount of scaled units to add (can be negative). * @return the updated time instant. */ public long add(long instant, int amount) { return getWrappedField().add(instant, amount * iDivisor); }
/** * Construct a DividedDateTimeField that compliments the given * RemainderDateTimeField. * * @param remainderField complimentary remainder field, like "yearOfCentury()". * @param rangeField the range field, null to derive * @param type the field type this field will actually use */ public DividedDateTimeField(RemainderDateTimeField remainderField, DurationField rangeField, DateTimeFieldType type) { super(remainderField.getWrappedField(), type); int divisor = iDivisor = remainderField.iDivisor; iDurationField = remainderField.iRangeField; iRangeDurationField = rangeField; DateTimeField field = getWrappedField(); int i = field.getMinimumValue(); int min = (i >= 0) ? i / divisor : ((i + 1) / divisor - 1); int j = field.getMaximumValue(); int max = (j >= 0) ? j / divisor : ((j + 1) / divisor - 1); iMin = min; iMax = max; }
/** * Get the amount of scaled units from the specified time instant. * * @param instant the time instant in millis to query. * @return the amount of scaled units extracted from the input. */ public int get(long instant) { int value = getWrappedField().get(instant); if (value >= 0) { return value / iDivisor; } else { return ((value + 1) / iDivisor) - 1; } }
/** * Construct a RemainderDateTimeField that compliments the given * DividedDateTimeField. * * @param dividedField complimentary divided field, like "century()". * @param type the field type this field actually uses */ public RemainderDateTimeField(DividedDateTimeField dividedField, DateTimeFieldType type) { this(dividedField, dividedField.getWrappedField().getDurationField(), type); }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { return getWrappedField().getDifferenceAsLong(minuendInstant, subtrahendInstant) / iDivisor; }
/** * Construct a RemainderDateTimeField that compliments the given * DividedDateTimeField. * * @param dividedField complimentary divided field, like "century()". */ public RemainderDateTimeField(DividedDateTimeField dividedField) { this(dividedField, dividedField.getType()); }
public DateTimeField getField(Chronology chronology) { return new DividedDateTimeField(chronology.yearOfCentury(), YearOfDecade, 10); } };
public int getDifference(long minuendInstant, long subtrahendInstant) { return getWrappedField().getDifference(minuendInstant, subtrahendInstant) / iDivisor; }
/** * Construct a RemainderDateTimeField that compliments the given * DividedDateTimeField. * This constructor allows the duration field to be set. * * @param dividedField complimentary divided field, like "century()". * @param durationField the duration field * @param type the field type this field actually uses */ public RemainderDateTimeField(DividedDateTimeField dividedField, DurationField durationField, DateTimeFieldType type) { super(dividedField.getWrappedField(), type); iDivisor = dividedField.iDivisor; iDurationField = durationField; iRangeField = dividedField.iDurationField; }
fields.year = new OffsetDateTimeField( new SkipUndoDateTimeField(this, field), BUDDHIST_OFFSET); fields.weekyear = new OffsetDateTimeField( new SkipUndoDateTimeField(this, field), BUDDHIST_OFFSET); field = new OffsetDateTimeField(fields.yearOfEra, 99); fields.centuryOfEra = new DividedDateTimeField( field, fields.eras, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField();
public long remainder(long instant) { return set(instant, get(getWrappedField().remainder(instant))); }
protected void assemble(Fields fields) { if (getBase().getZone() == DateTimeZone.UTC) { // Use zero based century and year of century. fields.centuryOfEra = new DividedDateTimeField( ISOYearOfEraDateTimeField.INSTANCE, DateTimeFieldType.centuryOfEra(), 100); fields.centuries = fields.centuryOfEra.getDurationField(); fields.yearOfCentury = new RemainderDateTimeField( (DividedDateTimeField) fields.centuryOfEra, DateTimeFieldType.yearOfCentury()); fields.weekyearOfCentury = new RemainderDateTimeField( (DividedDateTimeField) fields.centuryOfEra, fields.weekyears, DateTimeFieldType.weekyearOfCentury()); } }
/** * Add to the scaled component of the specified time instant, * wrapping around within that component if necessary. * * @param instant the time instant in millis to update. * @param amount the amount of scaled units to add (can be negative). * @return the updated time instant. */ public long addWrapField(long instant, int amount) { return set(instant, FieldUtils.getWrappedValue(get(instant), amount, iMin, iMax)); }