Java 中的时区获取保存()方法,示例
原文:https://www . geesforgeks . org/time zone-getdstssavings-method-in-Java-with-examples/
Java 中 TimeZone 类的getdstssaving()方法是用来知道需要加到本地标准时间的时间量来得到挂钟时间。
语法:
public int getDSTSavings()
参数:该方法不取任何参数。
返回值:该方法以毫秒为单位返回需要加入当地标准时间的时间量得到挂钟时间。这就是所谓的储蓄时间。
下面的程序说明了时区的 getDSTSavings()方法的工作: 示例 1:
// Java code to illustrate getDSTSavings() method
import java.util.*;
public class TimeZoneDemo {
public static void main(String args[])
{
// Creating a TimeZone
TimeZone offtime_zone
= TimeZone
.getTimeZone("Pacific/Pago_Pago");
// Knowing the DST
System.out.println("The DST is: "
+ offtime_zone.getDSTSavings());
}
}
Output:
The DST is: 0
例 2:
// Java code to illustrate getDSTSavings() method
import java.util.*;
public class TimeZoneDemo {
public static void main(String args[])
{
// Creating a TimeZone
TimeZone offtime_zone
= TimeZone.getTimeZone("Europe/Rome");
// Knowing the DST
System.out.println("The DST is: "
+ offtime_zone.getDSTSavings());
}
}
Output:
The DST is: 3600000
参考:https://docs . Oracle . com/javase/7/docs/API/Java/util/time zone . html # getdstssavings()
版权属于:月萌API www.moonapi.com,转载请注明出处