java timezone
TimeZone类setRawOffset()方法 (TimeZone Class setRawOffset() method)
setRawOffset() method is available in java.util package.
setRawOffset()方法在java.util包中可用。
setRawOffset() method is used to set the raw base time zone offset in ms.
setRawOffset()方法用于设置原始基准时区偏移量(以毫秒为单位)。
setRawOffset() 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.
setRawOffset()方法是一个非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。
setRawOffset() method does not throw an exception at the time of set raw offset in milliseconds.
setRawOffset()方法在设置原始偏移量(以毫秒为单位)时不会引发异常。
Syntax:
句法:
public abstract void setRawOffset(int offset_ms);
Parameter(s):
参数:
int offset_ms – represents the base time zone offset to GMT.
int offset_ms –表示相对于GMT的基准时区偏移量。
Return value:
返回值:
The return type of the method is void, it returns nothing.
该方法的返回类型为void ,不返回任何内容。
Example:
例:
// Java program to demonstrate the example
// of void setRawOffset(int offset_ms) method
// of TimeZone
import java.util.*;
public class SetRawOffSetOfTimeZone {
public static void main(String args[]) {
// Instantiates TimeZone object
TimeZone tz = TimeZone.getTimeZone("Africa/Asmera");
// Display Timezone Offset
System.out.println("tz.getRawOffset(): " + tz.getRawOffset());
// By using setRawOffset() method is to
// set the offset for this time zone tz
// Africa/Asmera
tz.setRawOffset(1100000);
// Display tz
System.out.println("tz.setID(Africa/Asmera): " + tz.getRawOffset());
}
}
Output
输出量
tz.getRawOffset(): 10800000
tz.setID(Africa/Asmera): 1100000
翻译自: https://www.includehelp.com/java/timezone-setrawoffset-method-with-example.aspx
java timezone