Java TimeZone getDSTSavings() Example
TimeZone class getDSTSavings() method example. This example shows you how to use getDSTSavings() method.
Syntax is : public int getDSTSavings()
Method returns the amount of time to be added to local standard time to get local wall clock time. The default implementation always returns 3600000 milliseconds (i.e., one hour) if this time zone observes Daylight Saving Time. Otherwise, 0 (zero) is returned.
Here is the code.
/**
* @(#) GetDSTSavingsTimeZone.java
* A class representing use of method getDSTSavings() of TimeZone
class in java.util Package.
* @Version 27-May-2008
* @author Rose India Team
*/
import java.util.*;
class GetDSTSavingsTimeZone {
public static void main( String args[] ){
// Create object of TimeZone class.
TimeZone obj = TimeZone.getDefault();
System.out.println("Object is : \n" + obj);
// getDSTSavings() method call.
int timeSave = obj.getDSTSavings();
System.out.println("Time saving for this time zone object is : "+timeSave);
}
} |
Output of the program.
object is :
sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false, transitions=0,lastRule=null]
Time saving for this time zone object is : 0 |
|