Friday, September 5, 2025
HomeLanguagesJavaTimeZone getDSTSavings() Method in Java with Examples

TimeZone getDSTSavings() Method in Java with Examples

The getDSTSavings() method of TimeZone class in Java is used to know the amount of time needed to be added to local standard time to get the wall clock time.

Syntax:

public int getDSTSavings()

Parameters: The method does not take any parameters.

Return Value: The method returns in milliseconds the amount of time needed to be added to local standard time to get the wall clock time. This is called the savings time.

Below programs illustrate the working of getDSTSavings() Method of TimeZone:
Example 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

Example 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

Reference: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#getDSTSavings()

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS