JDK Pit: 1 Fewer months in the calendar month in Java

Source: Internet
Author: User

Many friends in making the first use of the calendar, will find that the month is inexplicable, the results are always more than expected 1 months, check several times did not find the program is wrong, and began to freak. In fact, this time, just go to see the JDK will understand the problem. The JDK tells us that the month range of the Calendar class is [0,11], that is, the month starts at 0, while the others start at 1. So we need to do +1 of the month separately when we use calendar.

JDK Pit, remember ~

Edit by Jimmy

2014.09.24

JDK Pit: 1 Fewer months in the calendar month in Java

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.