In this section we are displaying the days of a specific month and the calendar format of the days for this month. We are also checking whether the year is leap or not.
Description of program:
In the given example first we are taking a string array monthcalendar that contains the name of the months of an year. After that we are creating an integer type array that contains number of days in the months in their respective order. Now we create a method displayMonth(). In this method we are leaving the number of days blank at the start of the month, throwing an illegalArgumentException object showing a message if the month value does not lie in between 0 and 11. Now we are creating an object cldr of the Gregoriancalendar class by passing the values of month and year and then printing the days of the week on the console. Now we are getting the number of days to be left blank at the start of a month by using the get() method of the Gregoriancalendar class and also checking whether the year is leap or not and printing the days of that month on the console.
Here is the output:
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial