GregorianCalendar.Add(CalendarField, Int32) Method

Definition

Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules.

[Android.Runtime.Register("add", "(II)V", "GetAdd_IIHandler")]
public override void Add (Java.Util.CalendarField field, int amount);
[<Android.Runtime.Register("add", "(II)V", "GetAdd_IIHandler")>]
override this.Add : Java.Util.CalendarField * int -> unit

Parameters

field
CalendarField

the calendar field.

amount
Int32

the amount of date or time to be added to the field.

Attributes

Exceptions

if the specified field is DST_OFFSET or ZONE_OFFSET.

Remarks

Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules.

<em>Add rule 1</em>. The value of field after the call minus the value of field before the call is amount, modulo any overflow that has occurred in field. Overflow occurs when a field value exceeds its range and, as a result, the next larger field is incremented or decremented and the field value is adjusted back into its range.

<em>Add rule 2</em>. If a smaller field is expected to be invariant, but it is impossible for it to be equal to its prior value because of changes in its minimum or maximum after field is changed, then its value is adjusted to be as close as possible to its expected value. A smaller field represents a smaller unit of time. HOUR is a smaller field than DAY_OF_MONTH. No adjustment is made to smaller fields that are not expected to be invariant. The calendar system determines what fields are expected to be invariant.

Java documentation for java.util.GregorianCalendar.add(int, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to