Thursday, June 11, 2026
HomeLanguagesJavaSimpleTimeZone setDSTSavings() method in Java with Examples

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:

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());    }}


Output:

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());    }}


Output:

Initially DST saving value is = 3500000
DST saving value set to 4000000
Current DST saving value is = 4000000
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6896 POSTS0 COMMENTS
Nicole Veronica
12012 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS