@Override public MonthDay parse(String text, Locale locale) throws ParseException { return MonthDay.parse(text); }
@Override public String print(MonthDay object, Locale locale) { return object.toString(); }
/** * Returns a copy of this month-day with the specified field set to a new value. * <p> * For example, if the field type is <code>dayOfMonth</code> then the day * would be changed in the returned instance. * <p> * These three lines are equivalent: * <pre> * MonthDay updated = md.withField(DateTimeFieldType.dayOfMonth(), 6); * MonthDay updated = md.dayOfMonth().setCopy(6); * MonthDay updated = md.property(DateTimeFieldType.dayOfMonth()).setCopy(6); * </pre> * * @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, never null * @throws IllegalArgumentException if the value is null or invalid */ public MonthDay 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 MonthDay(this, newValues); }
/** * Converts this object to a LocalDate with the same month-day and chronology. * * @param year the year to use, valid for chronology * @return a LocalDate with the same month-day and chronology, never null */ public LocalDate toLocalDate(int year) { return new LocalDate(year, getMonthOfYear(), getDayOfMonth(), getChronology()); }
/** * Returns a copy of this month-day with the month of year field updated. * <p> * MonthDay is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * month of year changed. * * @param monthOfYear the month of year to set * @return a copy of this object with the field set, never null * @throws IllegalArgumentException if the value is invalid */ public MonthDay withMonthOfYear(int monthOfYear) { int[] newValues = getValues(); newValues = getChronology().monthOfYear().set(this, MONTH_OF_YEAR, newValues, monthOfYear); return new MonthDay(this, newValues); }
return this; int[] newValues = getValues(); for (int i = 0; i < period.size(); i++) { DurationFieldType fieldType = period.getFieldType(i); int index = indexOf(fieldType); if (index >= 0) { newValues = getField(index).add(this, index, newValues, FieldUtils.safeMultiply(period.getValue(i), scalar)); return new MonthDay(this, newValues);
/** * Sets this field in a copy of the MonthDay. * <p> * The MonthDay attached to this property is unchanged by this call. * Instead, a new instance is returned. * * @param value the value to set the field in the copy to * @return a copy of the MonthDay with the field value changed * @throws IllegalArgumentException if the value isn't valid */ public MonthDay setCopy(int value) { int[] newValues = iBase.getValues(); newValues = getField().set(iBase, iFieldIndex, newValues, value); return new MonthDay(iBase, newValues); }
/** * Handle broken serialization from other tools. * @return the resolved object, not null */ private Object readResolve() { if (DateTimeZone.UTC.equals(getChronology().getZone()) == false) { return new MonthDay(this, getChronology().withUTC()); } return this; }
/** * Obtains a {@code MonthDay} set to the current system millisecond time * using <code>ISOChronology</code> in the default time zone. * The resulting object does not use the zone. * * @return the current month-day, not null * @since 2.0 */ public static MonthDay now() { return new MonthDay(); }
/** * Get the month of year field value. * * @return the month of year */ public int getMonthOfYear() { return getValue(MONTH_OF_YEAR); }
/** * Gets the field that this property uses. * * @return the field */ public DateTimeField getField() { return iBase.getField(iFieldIndex); }
return this; int[] newValues = getValues(); for (int i = 0; i < period.size(); i++) { DurationFieldType fieldType = period.getFieldType(i); int index = indexOf(fieldType); if (index >= 0) { newValues = getField(index).add(this, index, newValues, FieldUtils.safeMultiply(period.getValue(i), scalar)); return new MonthDay(this, newValues);
/** * Returns a copy of this month-day with the day of month field updated. * <p> * MonthDay is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * day of month changed. * * @param dayOfMonth the day of month to set * @return a copy of this object with the field set, never null * @throws IllegalArgumentException if the value is invalid */ public MonthDay withDayOfMonth(int dayOfMonth) { int[] newValues = getValues(); newValues = getChronology().dayOfMonth().set(this, DAY_OF_MONTH, newValues, dayOfMonth); return new MonthDay(this, newValues); }
/** * Converts this object to a LocalDate with the same month-day and chronology. * * @param year the year to use, valid for chronology * @return a LocalDate with the same month-day and chronology, never null */ public LocalDate toLocalDate(int year) { return new LocalDate(year, getMonthOfYear(), getDayOfMonth(), getChronology()); }
/** * Sets this field in a copy of the MonthDay to a parsed text value. * <p> * The MonthDay attached to this property is unchanged by this call. * Instead, a new instance is returned. * * @param text the text value to set * @param locale optional locale to use for selecting a text symbol * @return a copy of the MonthDay with the field value changed * @throws IllegalArgumentException if the text value isn't valid */ public MonthDay setCopy(String text, Locale locale) { int[] newValues = iBase.getValues(); newValues = getField().set(iBase, iFieldIndex, newValues, text, locale); return new MonthDay(iBase, newValues); }
/** * Handle broken serialization from other tools. * @return the resolved object, not null */ private Object readResolve() { if (DateTimeZone.UTC.equals(getChronology().getZone()) == false) { return new MonthDay(this, getChronology().withUTC()); } return this; }
/** * Obtains a {@code MonthDay} set to the current system millisecond time * using <code>ISOChronology</code> in the default time zone. * The resulting object does not use the zone. * * @return the current month-day, not null * @since 2.0 */ public static MonthDay now() { return new MonthDay(); }
/** * Get the day of month field value. * * @return the day of month */ public int getDayOfMonth() { return getValue(DAY_OF_MONTH); }
/** * Gets the field that this property uses. * * @return the field */ public DateTimeField getField() { return iBase.getField(iFieldIndex); }
return this; int[] newValues = getValues(); for (int i = 0; i < period.size(); i++) { DurationFieldType fieldType = period.getFieldType(i); int index = indexOf(fieldType); if (index >= 0) { newValues = getField(index).add(this, index, newValues, FieldUtils.safeMultiply(period.getValue(i), scalar)); return new MonthDay(this, newValues);