The setDSTSavings() method of SimpleTimeZone class is used to set the amount of time that the clock is advanced during daylight saving time. The calculation is done in milliseconds.
Syntax:
public void setDSTSavings(int millisSavedDuringDST)
Parameters: The function accepts a single parameter millisSavedDuringDST which specifies the number of milliseconds the time is advanced with respect to standard time.
Return Value: The method has no return value.
Exception: The function does not throws any exception.
Program below demonstrates the above mentioned function:
Program 1:
Java
// program to demonstrate the// function SimpleTimeZone.setDSTSavings()import java.util.*;public class GFG { public static void main(String[] args) { // create simple time zone object SimpleTimeZone obj = new SimpleTimeZone(-28800000, "US", Calendar.MAY, 1, -Calendar.SUNDAY, 7200000, Calendar.NOVEMBER, -1, Calendar.MONDAY, 7000000, 3500000); // printing DST value System.out.println("Initially DST saving value is = " + obj.getDSTSavings()); // setting DST saving time on object obj obj.setDSTSavings(6000000); System.out.println("DST saving value " + "set to 6000000"); // printing DST value System.out.println("Current DST saving value is = " + obj.getDSTSavings()); }} |
Initially DST saving value is = 3500000 DST saving value set to 6000000 Current DST saving value is = 6000000
Program 2:
Java
// program to demonstrate the// function SimpleTimeZone.setDSTSavings()import java.util.*;public class GFG { public static void main(String[] args) { // create simple time zone object SimpleTimeZone obj = new SimpleTimeZone(-28800000, "US", Calendar.MAY, 1, -Calendar.MONDAY, 7200000, Calendar.JULY, -1, Calendar.MONDAY, 7000000, 3500000); // printing DST value System.out.println("Initially DST saving value is = " + obj.getDSTSavings()); // setting DST saving time on object obj obj.setDSTSavings(4000000); System.out.println("DST saving value " + "set to 4000000"); // printing DST value System.out.println("Current DST saving value is = " + obj.getDSTSavings()); }} |
Initially DST saving value is = 3500000 DST saving value set to 4000000 Current DST saving value is = 4000000