Calendar类

Calendar所包含的所有有关知识(Locale、TimeZone、Calendar...),每一块都设计一个相关的知识 

 1 import java.util.Calendar;
2 import java.util.Locale;
3 import java.util.TimeZone;
4
5
6 public class CalendarTest {
7 public static void main(String[] args) {
8
/*
Locale有关知识
*/
9 /*获得本地化的所有实例,返回所有语言环境的数组*/
10 Locale []locale = Calendar.getAvailableLocales();
11 System.out.println("本地共有 " + locale.length + "个实例化的Locale的对象");
12 System.out.println("本地Locale所有实例化对象如下 : ");
13 for(int i = 0;i < locale.length;i++)
14 {
15 System.out.print(locale[i]);
16 System.out.print((0 == (i + 1) % 15)? "\n":" ");
17 }
18 System.out.println();
19
20
21
22 /*
23 * 时区的有关知识
24 */
25 /*获得默认的时区*/
26 TimeZone timeZone = TimeZone.getDefault();
27 System.out.println("系统默认的时区 :" + timeZone);

28 /*获得所有的时区*/
29 String []ids = timeZone.getAvailableIDs();
30 TimeZone []timeZones = new TimeZone[ids.length];
31 System.out.println("一共有 " + ids.length + "个时区");
32 System.out.println("所有的时区 :");
33 /* 一共有611个时区,因为太多,这里就不过多的打印了
34 * for(int j = 0;j < ids.length;j++)
35 {
36 timeZones[j] = timeZone.getTimeZone(ids[j]);
37 System.out.print(timeZones[j]);
38 System.out.print((0 == (j + 1) % 15)? "\n":" ");
39 }*/
40
41
42 /*
43 *Calendar类的有关知识
44 */
45 }
46 }
posted @ 2012-01-30 01:46  Idéal-付理想  阅读(197)  评论(0)    收藏  举报