SimpleTimeZone setDSTSavings() method in Java with Examples
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:
// 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("Inittally 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()); } } |
Inittally DST saving value is = 3500000 DST saving value set to 6000000 Current DST saving value is = 6000000
Program 2:
// 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("Inittally 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()); } } |
Inittally DST saving value is = 3500000 DST saving value set to 4000000 Current DST saving value is = 4000000
Recommended Posts:
- SimpleTimeZone equals() method in Java with Examples
- SimpleTimeZone getOffset() method in Java with Examples
- SimpleTimeZone clone() method in Java with Examples
- SimpleTimeZone hasSameRules() method in Java with Examples
- SimpleTimeZone setRawOffset() method in Java with Examples
- SimpleTimeZone getDSTSavings() method in Java with Examples
- SimpleTimeZone toString() method in Java with Examples
- SimpleTimeZone getRawOffset() method in Java with Examples
- SimpleTimeZone setEndRule(int, int, int) method in Java with Examples
- SimpleTimeZone setStartRule(int, int, int) method in Java with Examples
- SimpleTimeZone inDaylightTime() method in Java with Examples
- SimpleTimeZone hashCode() method in Java with Examples
- SimpleTimeZone setStartYear() method in Java
- SimpleTimeZone useDaylightTime() method in Java
- Java.util.Collections.disjoint() Method in java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet



