/** * Gets the value of this field. * * @return the field value */ public int get() { return iPartial.getValue(iFieldIndex); }
/** * Gets a copy of this Partial with the specified field set to a new value. * <p> * If this partial does not support the field, an exception is thrown. * Contrast this behaviour with {@link #with(DateTimeFieldType, int)}. * <p> * For example, if the field type is <code>dayOfMonth</code> then the day * would be changed in the returned instance if supported. * * @param fieldType the field type to set, not null * @param value the value to set * @return a copy of this instance with the field set * @throws IllegalArgumentException if the value is null or invalid */ public Partial withField(DateTimeFieldType fieldType, int value) { int index = indexOfSupported(fieldType); if (value == getValue(index)) { return this; } int[] newValues = getValues(); newValues = getField(index).set(this, index, newValues, value); return new Partial(this, newValues); }
/** * Gets a copy of this Partial with the specified field set to a new value. * <p> * If this partial does not support the field, an exception is thrown. * Contrast this behaviour with {@link #with(DateTimeFieldType, int)}. * <p> * For example, if the field type is <code>dayOfMonth</code> then the day * would be changed in the returned instance if supported. * * @param fieldType the field type to set, not null * @param value the value to set * @return a copy of this instance with the field set * @throws IllegalArgumentException if the value is null or invalid */ public Partial withField(DateTimeFieldType fieldType, int value) { int index = indexOfSupported(fieldType); if (value == getValue(index)) { return this; } int[] newValues = getValues(); newValues = getField(index).set(this, index, newValues, value); return new Partial(this, newValues); }
/** * Gets the value of this field. * * @return the field value */ public int get() { return iPartial.getValue(iFieldIndex); }
return newPartial; if (value == getValue(index)) { return this;
public static Partial withWeekYear(Partial p) { Partial res = new Partial(); for (int i = 0; i < p.size(); i++) { DateTimeFieldType fieldType = p.getFieldType(i); if (fieldType == DateTimeFieldType.year()) { res = res.with(DateTimeFieldType.weekyear(), p.getValue(i)); } else { res = res.with(fieldType, p.getValue(i)); } } return res; }
return newPartial; if (value == getValue(index)) { return this;
public static boolean isCompatible(Partial p1, Partial p2) { if (p1 == null) return true; if (p2 == null) return true; for (int i = 0; i < p1.size(); i++) { DateTimeFieldType type = p1.getFieldType(i); int v = p1.getValue(i); if (JodaTimeUtils.hasField(p2,type)) { if (v != p2.get(type)) { return false; } } } return true; } // Uses p2 to resolve dow for p1
/** * Gets a copy of this Partial with the specified field set to a new value. * <p> * If this partial does not support the field, an exception is thrown. * Contrast this behaviour with {@link #with(DateTimeFieldType, int)}. * <p> * For example, if the field type is <code>dayOfMonth</code> then the day * would be changed in the returned instance if supported. * * @param fieldType the field type to set, not null * @param value the value to set * @return a copy of this instance with the field set * @throws IllegalArgumentException if the value is null or invalid */ public Partial withField(DateTimeFieldType fieldType, int value) { int index = indexOfSupported(fieldType); if (value == getValue(index)) { return this; } int[] newValues = getValues(); newValues = getField(index).set(this, index, newValues, value); return new Partial(this, newValues); }
public static Partial discardMoreSpecificFields(Partial p, DurationFieldType dft) { DurationField df = dft.getField(p.getChronology()); Partial res = new Partial(); for (int i = 0; i < p.size(); i++) { DateTimeFieldType fieldType = p.getFieldType(i); DurationField f = fieldType.getDurationType().getField(p.getChronology()); int cmp = df.compareTo(f); if (cmp <= 0) { res = res.with(fieldType, p.getValue(i)); } } return res; }
return newPartial; if (value == getValue(index)) { return this;
public static Partial discardMoreSpecificFields(Partial p, DateTimeFieldType d) { Partial res = new Partial(); for (int i = 0; i < p.size(); i++) { DateTimeFieldType fieldType = p.getFieldType(i); if (fieldType.equals(d) || isMoreGeneral(fieldType, d, p.getChronology())) { res = res.with(fieldType, p.getValue(i)); } } if (res.isSupported(JodaTimeUtils.DecadeOfCentury) && !res.isSupported(DateTimeFieldType.centuryOfEra())) { if (p.isSupported(DateTimeFieldType.year())) { res = res.with(DateTimeFieldType.centuryOfEra(), p.get(DateTimeFieldType.year()) / 100); } } return res; }
/** * Gets the value of this field. * * @return the field value */ public int get() { return iPartial.getValue(iFieldIndex); }
if (!p.isSupported(DateTimeFieldType.centuryOfEra())) { int yoc = p.get(DateTimeFieldType.yearOfCentury()); int refYear = p2.getValue(i); int century = refYear / 100; int y2 = yoc + century*100; if (!p.isSupported(DateTimeFieldType.centuryOfEra())) { int decade = p.get(JodaTimeUtils.DecadeOfCentury); int refYear = p2.getValue(i); int century = refYear / 100; int y2 = decade*10 + century*100; p = p.with(fieldType, p2.getValue(i));
p = p.with(fieldType, p2.getValue(i));
/** * Gets the value of this field. * * @return the field value */ public int get() { return iPartial.getValue(iFieldIndex); }
/** * Gets the value of this field. * * @return the field value */ public int get() { return iPartial.getValue(iFieldIndex); }
/** * Gets the value of this field. * * @return the field value */ public int get() { return iPartial.getValue(iFieldIndex); }
public static boolean isUncertain(Time t, String precision) { try { t.getPartial().getValue(Time.getFieldIndex(precision)); } catch (IndexOutOfBoundsException e) { return true; } return false; }