Roll method of Java. util. Calendar

Source: Internet
Author: User
Document directory
  • Roll

Do not read the JDK document.

In the original sense, roll can directly handle date changes. No. Check the JDK documentation as follows:

Roll
public void roll(int field,                 int amount)
Time Field Rolling function. add to field a signed amount without changing larger fields. A negative roll amount means to roll down. [Note: this default implementation on calendar just repeatedly cballs the version of roll () that takes a Boolean and rolls by one unit. this may not always do the right thing. for example, if the day_of_month field is 31, rolling through February will leave it set to 28. the gregoriancalendar version of this function takes care of this problem. other subclasses shoshould also provide overrides of this function that do the right thing.

Parameters:
field-The time field.
amount-The signed amount to add field.
Since:
1.2
See also:
add(int, int), set(int, int)

Shit, you should use add

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.