導入Java . util . calendar;
導入Java . util . scanner;
公共類測試{
靜態公共void main(String參數[]) {
calendar c = calendar . getinstance();
Scanner sc =新掃描儀(system . in);
System.out.println("請輸入年份:");
int year = sc . nextint();
c.set(日歷。年、年);
c.set(日歷。月份,日歷。1月);
c.set(日歷。月日,1);
while(c.get(日歷。YEAR)==year){
int wday=c.get(日歷。星期幾);
int mday=c.get(日歷。月日);
if(mday==1){
system . out . println(" \ n day \ t one \ t two \ t three \ t four \ t five \ t six \ t the first "+(c . get(calendar . month)+1)+" month ");
system . out . println("-");
for(int I = 0;我& ltwday-1;i++)system . out . print(" \ t ");
}
system . out . print(mday+" \ t ");
if(wday = = 7)system . out . println();
c.add(日歷。壹年中的某壹天,1);
}
}
}
=======
請輸入年份:
2012
1月的第1、2、3、4、5、6天
-
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
2月123456日
-
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
第壹二三四五六天第三個月
-
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
4月123456日
-
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
第123456天五月
-
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
6月123456日
-
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
7月123456日
-
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
8月123456日
-
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
9月123456日
-
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
第壹、二、三、四、五、六天,10月
-
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
第123456天第65438號+01月
-
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
第123456天65438+二月
-
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