Returns a copy of this date with the specified field set to a new value.
For example, if the field type is dayOfMonth
then the day of month field would be changed in the returned instance. If the field type is null, then this
is returned.
These three lines are equivalent:
DateTime updated = dt.withField(DateTimeFieldType.dayOfMonth(), 6); DateTime updated = dt.dayOfMonth().setCopy(6); DateTime updated = dt.property(DateTimeFieldType.dayOfMonth()).setCopy(6);
@param fieldType the field type to set, not null
@param value the value to set
@return a copy of this datetime with the field set
@throws IllegalArgumentException if the value is null or invalid