码迷,mamicode.com
首页 > 其他好文 > 详细

Calendar类的基本使用

时间:2016-06-21 15:17:45      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

import java.util.Calendar;


public class CalendarDemo{
public static void main(String[] args) {
Calendar c=Calendar.getInstance();
System.out.println(c.get( Calendar.YEAR));
System.out.println(c.get(Calendar.MONTH));
System.out.println(c.get(Calendar.DAY_OF_MONTH));
System.out.println(c.get(Calendar.DAY_OF_WEEK));
c.set(Calendar.YEAR ,3000);
System.out.println(getWeek(c));
}

private static String getWeek(Calendar c) {
String []str={"星期一","星期二", "星期三","星期四","星期五","星期六","星期天"};
return str[c.DAY_OF_WEEK-1];
}
}

Calendar类的基本使用

标签:

原文地址:http://www.cnblogs.com/1314wamm/p/5603450.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!