Calendar set() Method in Java with Examples
The set(int calndr_field, int new_val) method in Calendar class is used to set the calndr_field value to a new_val. The older field of this calendar get replaced by a new field.
public void set(int calndr_field, int new_val)
Parameters: The method takes two parameters:
- calndr_field: This is of Calendar type and refers to the field of the calendar that is to be altered.
- new_val: This refers to the new value that is to be replaced with.
Return Value: The method does not return any value.
Below programs illustrate the working of set() Method of Calendar class:
The Current Month is: 1 Altered Month is: 11
The Current year is: 2019 Altered year is: 1996
My Personal Notes arrow_drop_up
Please Login to comment...