Refine search
@Override public DurationField getField(Chronology chronology) { return new ScaledDurationField(chronology.months(), QUARTER_OF_YEAR_DURATION_FIELD_TYPE, 3); } }
/** * Gets a hash code for this instance. * * @return a suitable hashcode */ public int hashCode() { long scalar = iScalar; int hash = (int) (scalar ^ (scalar >>> 32)); hash += getType().hashCode(); hash += getWrappedField().hashCode(); return hash; }
public long getMillis(int value) { long scaled = ((long) value) * ((long) iScalar); return getWrappedField().getMillis(scaled); }
public long add(long instant, int value) { long scaled = ((long) value) * ((long) iScalar); return getWrappedField().add(instant, scaled); }
protected static Period getJodaTimePeriod(Partial p) { if (p.size() > 0) { DateTimeFieldType dtType = p.getFieldType(p.size()-1); DurationFieldType dType = dtType.getDurationType(); Period period = new Period(); if (period.isSupported(dType)) { return period.withField(dType, 1); } else { DurationField df = dType.getField(p.getChronology()); if (df instanceof ScaledDurationField) { ScaledDurationField sdf = (ScaledDurationField) df; return period.withField(sdf.getWrappedField().getType(), sdf.getScalar()); } // PeriodType.forFields(new DurationFieldType[]{dType}); // return new Period(df.getUnitMillis(), PeriodType.forFields(new DurationFieldType[]{dType})); } } return null; } public static Partial combineMoreGeneralFields(Partial p1, Partial p2) {
public long getUnitMillis() { return getWrappedField().getUnitMillis() * iScalar; }
public int getDifference(long minuendInstant, long subtrahendInstant) { return getWrappedField().getDifference(minuendInstant, subtrahendInstant) / iScalar; }
public int getValue(long duration, long instant) { return getWrappedField().getValue(duration, instant) / iScalar; }
public long getValueAsLong(long duration) { return getWrappedField().getValueAsLong(duration) / iScalar; }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { return getWrappedField().getDifferenceAsLong(minuendInstant, subtrahendInstant) / iScalar; }
public long getMillis(int value, long instant) { long scaled = ((long) value) * ((long) iScalar); return getWrappedField().getMillis(scaled, instant); }
public long add(long instant, int value) { long scaled = ((long) value) * ((long) iScalar); return getWrappedField().add(instant, scaled); }
protected static Period getJodaTimePeriod(Partial p) { if (p.size() > 0) { DateTimeFieldType dtType = p.getFieldType(p.size()-1); DurationFieldType dType = dtType.getDurationType(); Period period = new Period(); if (period.isSupported(dType)) { return period.withField(dType, 1); } else { DurationField df = dType.getField(p.getChronology()); if (df instanceof ScaledDurationField) { ScaledDurationField sdf = (ScaledDurationField) df; return period.withField(sdf.getWrappedField().getType(), sdf.getScalar()); } // PeriodType.forFields(new DurationFieldType[]{dType}); // return new Period(df.getUnitMillis(), PeriodType.forFields(new DurationFieldType[]{dType})); } } return null; } public static Partial combineMoreGeneralFields(Partial p1, Partial p2) {
public long getUnitMillis() { return getWrappedField().getUnitMillis() * iScalar; }
public int getDifference(long minuendInstant, long subtrahendInstant) { return getWrappedField().getDifference(minuendInstant, subtrahendInstant) / iScalar; }
public int getValue(long duration) { return getWrappedField().getValue(duration) / iScalar; }
public long getValueAsLong(long duration, long instant) { return getWrappedField().getValueAsLong(duration, instant) / iScalar; }
public long getDifferenceAsLong(long minuendInstant, long subtrahendInstant) { return getWrappedField().getDifferenceAsLong(minuendInstant, subtrahendInstant) / iScalar; }
public DurationField getField(Chronology chronology) { return new ScaledDurationField(chronology.months(), Quarters, 3); } };
/** * Compares this duration field to another. * Two fields are equal if of the same type and duration. * * @param obj the object to compare to * @return if equal */ public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj instanceof ScaledDurationField) { ScaledDurationField other = (ScaledDurationField) obj; return (getWrappedField().equals(other.getWrappedField())) && (getType() == other.getType()) && (iScalar == other.iScalar); } return false; }