java timezone
TimeZone类的getID()方法 (TimeZone Class getID() method)
getID() method is available in java.util package.
getID()方法在java.util包中可用。
getID() method is used to return the ID of this TimeZone.
getID()方法用于返回此TimeZone的ID。
getID() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
getID()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
getID() method does not throw an exception at the time of returning ID.
返回ID时, getID()方法不会引发异常。
Syntax:
句法:
public String getID();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of the method is String, it gets ID of this TimeZone.
该方法的返回类型为String ,它获取此TimeZone的ID。
Example:
例:
// Java program to demonstrate the example
// of String getID() method of TimeZone
import java.util.*;
public class GetIDOfTimeZone {
public static void main(String args[]) {
// By using getTimeZone() method is
// to get the time zone
TimeZone tz = TimeZone.getTimeZone("Africa/Asmera");
// By using getID() method is to
// return the id of the time zone
// Africa/Asmera
System.out.print("tz.getID(): ");
System.out.println(tz.getID());
}
}
Output
输出量
tz.getID(): Africa/Asmera
翻译自: https://www.includehelp.com/java/timezone-getid-method-with-example.aspx
java timezone