题目:编写一个输出如下图的日历程序.
2008年1月
日 一 二 三 四 五 六
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
2008年1月
日 一 二 三 四 五 六
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
解决方案 »
- JCreator编译出错
- 一行SQL更新语句,在SQL工具中能执行通过,但在Java中用JDBC中更新却失败,请问这是什么原因?
- Hibernate能否返回顺序的map啊!奇怪的需求。。。555
- 帮我看一下.谢了...
- JRE都在 Jdk\jre\ 目录下吗?那 \JDK\LIB\目录下的内容难道不是JRE的组成部分吗?
- java能否在类的实例被销毁之前执行某些代码?
- 接口类与对象类型转换
- 简单的连接sqlserver数据库问题(在线等)
- 想用irc写一个类似icq的东东,请大家支持支持
- 有一个需求,新用户注册,注册成功10天未缴费,发邮件提醒,如何实现
- 如何选择的文件并保存在指定的目录中
- 如何向jar包中写文件
static void getCalendar(){
int year=2004;
int month=10;
Calendar c = GregorianCalendar.getInstance();
c.set(Calendar.YEAR, year);//2004年
c.set(Calendar.MONTH, month-1);//10月
c.set(Calendar.DAY_OF_MONTH, 1);//1日
System.out.println(c.get(Calendar.YEAR)+"年"+(c.get(Calendar.MONTH)+1)+"月");
System.out.println("日 一 二 三 四 五 六");
int[][] day = new int[6][7];
while(c.get(Calendar.MONTH)+1==month){
int i=c.get(Calendar.WEEK_OF_MONTH)-1;
int j=c.get(Calendar.DAY_OF_WEEK)-1;
day[i][j] = c.get(Calendar.DAY_OF_MONTH);
c.add(Calendar.DATE, 1);
}
for(int i=0;i<6;i++){
for(int j=0;j<7;j++){
String out = day[i][j]+"";
if(out.equals("0"))out=" ";
if(out.length()==1)out=" "+out;
System.out.print(out+" ");
} System.out.println();
}
}