import java.util.Calendar;
public class Test_Calendar01 {
public static void main(String[] args) {
Calendar c = Calendar.getInstance();
c.set(2008, 8, 8);
System.out.println(c.get(Calendar.YEAR) + "年"
+ getNum(c.get(Calendar.MONTH)) + "月"
+ getNum(c.get(Calendar.DAY_OF_MONTH)) + "日"
+ getWeek(c.get(Calendar.DAY_OF_WEEK)));
}
public static String getWeek(int week) {
String[] arr = { "", "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
return arr[week];
}
public static String getNum(int i) {
return i >= 9 ? "" + i : "0" + i;
}
}
|