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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

Inittally DST saving value is = 3500000
DST saving value set to 6000000
Current DST saving value is = 6000000

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

Inittally DST saving value is = 3500000
DST saving value set to 4000000
Current DST saving value is = 4000000


My Personal Notes arrow_drop_up

Contented with little yet wishing for more

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



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.