Home > Computer Tutorials > Computer Knowledge > Java programming to implement a program to calculate the number of days in each month

Java programming to implement a program to calculate the number of days in each month

WBOY
Release: 2024-01-20 12:30:17
forward
642 people have browsed it

Java programming to implement a program to calculate the number of days in each month

Write a java program to print out how many days there are in each month of 112

This can be achieved through Calendar’s own methods. code show as below:

int intYear = 2015; //Define the year to be queried

for(int i=1;i

Calendar cal = Calendar.getInstance(); //Get the instance of the calendar function

cal.set(Calendar.YEAR, intYear); //Set the year to the year just set

cal.set(Calendar.MONTH, i - 1); //The month subscript cycles from 0 to 11

cal.set(Calendar.DAY_OF_MONTH, 1); //Get the value of the month

int value = cal.getActualMaximum(Calendar.DAY_OF_MONTH); //Get the value of the largest day of the month

System.out.println(intYear "Year" i "Month:" value "Day"); //Output the result.

}

Need full year calendar from 2003 to 2007

January 2003

日 一二 三 四 五 六

1 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 30 31

February 2003

日 一二 三 四 五 六

1

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

March 2003

日 一二 三 四 五 六

1

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

30 31

April 2003

日 一二 三 四 五 六

1 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 30

May 2003

日 一二 三 四 五 六

1 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 30 31

June 2003

日 一二 三 四 五 六

1 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 30

July 2003

日 一二 三 四 五 六

1 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 30 31

August 2003

日 一二 三 四 五 六

1 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 30

31

September 2003

日 一二 三 四 五 六

1 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 30

October 2003

日 一二 三 四 五 六

1 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 30 31

November 2003

日 一二 三 四 五 六

1

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

30

December 2003

日 一二 三 四 五 六

1 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 30 31

There is a problem with the spaces displayed on the web page. If this is possible, please send me a message. I'll send it to you in text form via email. Any year will do.

The above is the detailed content of Java programming to implement a program to calculate the number of days in each month. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:docexcel.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template