In this section, you will learn how to obtain the number of days in the specified month.
This example sets the year as 2008, month as Calendar.FEBRUARY and the date as 1 using the method calendar.set(year, month, date) provided by the class Calendar. The Calendar class extends Object class. Calendar class provides a getInstance() method that returns a Calendar object. Here we are going to get the number of days in the month February.
Here is the code of GetDaysInMonth.java
Output will be displayed as:
We have 1000s of tutorials on our website. Search Tutorials tutorials on our website.
Posted on: November 1, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles