java.util.GregorianCalendar.getTimeZone()%uA0方法获取的时区。
声明
以下是java.util.GregorianCalendar.getTimeZone()方法的声明
public TimeZone getTimeZone()
参数
-
NA
返回值
此方法返回与此日历有关的时区对象。
异常
-
NA
例子
下面的示例演示java.util.GregorianCalendar.getTimeZone()方法的用法。
package com.yiibai import java.util.* public class GregorianCalendarDemo { public static void main(String[] args) { // create a new calendar GregorianCalendar cal = (GregorianCalendar) GregorianCalendar.getInstance() // print the current date and time System.out.println("" + cal.getTime()) // get the time zone and print it System.out.println("Time Zone:" + cal.getTimeZone().getDisplayName()) } }
让我们来编译和运行上面的程序,这将产生以下结果:
Fri May 18 12:43:05 EEST 2012 Time Zone:Eastern European Time