Java-util-calendar-gettimezone
提供:Dev Guides
Java.util.Calendar.getTimeZone()メソッド
説明
- java.util.Calendar.getTimeZone()*メソッドはタイムゾーンを取得します。
宣言
以下は* java.util.Calendar.getTimeZone()*メソッドの宣言です
public TimeZone getTimeZone()
パラメーター
NA
戻り値
メソッドはタイムゾーンオブジェクトを返します。
例外
NA
例
次の例は、java.util.calendar.getTimeZone()メソッドの使用法を示しています。
package com.finddevguides;
import java.util.*;
public class CalendarDemo {
public static void main(String[] args) {
//create a calendar
Calendar cal = Calendar.getInstance();
//get the time zone
TimeZone tz = cal.getTimeZone();
//print the time zone name for this calendar
System.out.println("The time zone is :" + tz.getDisplayName());
}
}
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-
The time zone is :Eastern European Time