Java Calendar roll() MethodThe roll () method of Calendar class increases or decreases the specified calendar field by one unit without affecting the other field. For example, if the YEAR field is passed as the parameter. It will roll only the YEAR field. The roll() method is overloaded as roll(int field, int amount) in which, the amount of time is passed to roll the specified field by that amount of time. SyntaxParameterfield - the calendar field. up - indicates if the value of the specified time field is to be rolled up or rolled down. Use true if rolling up, false otherwise. ReturnsNA ThrowsNA Example 1Output: Date : Tue Aug 14 17:38:23 PDT 2018 Date after rolling : Sun Sep 08 17:38:23 PDT 2019 Example 2Output: Date : Tue Aug 14 17:42:25 PDT 2018 Date after rolling : Sun Oct 10 19:51:28 PDT 2027 Next TopicJava-calendar-setfirstdayofweek-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India