Java Calendar set() MethodThe set() method of Calendar class is used to set the specified calendar field by the specified value. SyntaxThis method is overloaded in the following ways. Parameterfield - the calendar field. Value ? this passed value is set to specified calendar field as the parameter. ReturnsNA ThrowsNA Example 1Test it NowOutput: Today :Tue Aug 14 17:53:46 PDT 2018 Year :2018 Month :7 Day :3 Now Today :Sun Jun 23 10:15:20 PDT 1996 Now Year :1996 Now Month :5 Now Day :1 Example 2Test it NowOutput: Today :Tue Aug 14 17:58:18 PDT 2018 Altered Date(1) :Wed Aug 14 17:58:18 PDT 1996 Altered Date (2) :Wed Oct 23 17:58:18 PDT 1996
Next TopicJava Calendar Class
|