黑马程序员技术交流社区
标题:
自己写个打印时间小代码
[打印本页]
作者:
途中ms前进
时间:
2015-5-25 22:03
标题:
自己写个打印时间小代码
本帖最后由 途中ms前进 于 2015-5-25 22:24 编辑
class CalendarDemo2
{
public static void main(String[] args)
{Calendar c=Calendar.getInstance();
c.set(2012,1,2);
printCalendar(c);
}
public static void printCalendar(Calendar c)
{ String[] months={"一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};
String[] weeks={"","星期天","星期一","星期二","星期三","星期四","星期五","星期六"};
sop(c.get(Calendar.YEAR)+"年");
int index=c.get(Calendar.MONTH);
sop(months[index]);
sop(c.get(Calendar.DAY_OF_MONTH)+"日");
int index1=c.get(Calendar.DAY_OF_WEEK);
sop(weeks[index1]);
}
public static void sop(Object obj)
{
System.out.println(obj);}
}
作者:
ZYZQ
时间:
2015-5-26 01:03
何不继承Calendar
作者:
871165471@qq.co
时间:
2015-5-26 03:40
有啊?
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2