- Java.util Package Classes
- Java.util - Home
- Java.util - ArrayDeque
- Java.util - ArrayList
- Java.util - Arrays
- Java.util - BitSet
- Java.util - Calendar
- Java.util - Collections
- Java.util - Currency
- Java.util - Date
- Java.util - Dictionary
- Java.util - EnumMap
- Java.util - EnumSet
- Java.util - Formatter
- Java.util - GregorianCalendar
- Java.util - HashMap
- Java.util - HashSet
- Java.util - Hashtable
- Java.util - IdentityHashMap
- Java.util - LinkedHashMap
- Java.util - LinkedHashSet
- Java.util - LinkedList
- Java.util - ListResourceBundle
- Java.util - Locale
- Java.util - Observable
- Java.util - PriorityQueue
- Java.util - Properties
- Java.util - PropertyPermission
- Java.util - PropertyResourceBundle
- Java.util - Random
- Java.util - ResourceBundle
- Java.util - ResourceBundle.Control
- Java.util - Scanner
- Java.util - ServiceLoader
- Java.util - SimpleTimeZone
- Java.util - Stack
- Java.util - StringTokenizer
- Java.util - Timer
- Java.util - TimerTask
- Java.util - TimeZone
- Java.util - TreeMap
- Java.util - TreeSet
- Java.util - UUID
- Java.util - Vector
- Java.util - WeakHashMap
- Java.util Package Extras
- Java.util - Interfaces
- Java.util - Exceptions
- Java.util - Enumerations
- Java.util Useful Resources
- Java.util - Useful Resources
- Java.util - Discussion
Java SimpleTimeZone setDSTSavings() Method
Description
The Java SimpleTimeZone setDSTSavings(int millisSavedDuringDST) method is used to set the amount of time in milliseconds that the clock is advanced during daylight saving time.
Declaration
Following is the declaration for java.util.SimpleTimeZone.setDSTSavings() method.
public void setDSTSavings(int millisSavedDuringDST)
Parameters
millisSavedDuringDST − This is the the number of milliseconds the time is advanced with respect to standard time.
Return Value
NA
Exception
NA
Setting DST Savings for a SimpleTimeZone Instance of Indian Zone
The following example shows the usage of Java SimpleTimeZone setDSTSavings() method to advance the time with respect to standard time. We've created a SimpleTimeZone using India. Then we've advanced the time using setDSTSavings() method and printed the status using getDSTSavings() method.
package com.tutorialspoint; import java.util.Calendar; import java.util.SimpleTimeZone; public class SimpleTimeZoneDemo { public static void main( String args[] ) { // create simple time zone object SimpleTimeZone stobj = new SimpleTimeZone(-28800000, "India", Calendar.MAY, 1,-Calendar.SUNDAY, 7200000, Calendar.OCTOBER, -1, Calendar.MONDAY, 7200000, 3600000); // setting DST saving time stobj.setDSTSavings(5400000); // checking the value System.out.println("DST saving value : " + stobj.getDSTSavings()); } }
Output
Let us compile and run the above program, this will produce the following result.
DST saving value : 5400000
Setting DST Savings for a SimpleTimeZone Instance of GMT Zone
The following example shows the usage of Java SimpleTimeZone setDSTSavings() method to advance the time with respect to standard time. We've created a SimpleTimeZone using GMT. Then we've advanced the time using setDSTSavings() method and printed the status using getDSTSavings() method.
package com.tutorialspoint; import java.util.Calendar; import java.util.SimpleTimeZone; public class SimpleTimeZoneDemo { public static void main( String args[] ) { // create simple time zone object SimpleTimeZone stobj = new SimpleTimeZone(-28800000, "GMT", Calendar.MAY, 1,-Calendar.SUNDAY, 7200000, Calendar.OCTOBER, -1, Calendar.MONDAY, 7200000, 3600000); // setting DST saving time stobj.setDSTSavings(5400000); // checking the value System.out.println("DST saving value : " + stobj.getDSTSavings()); } }
Output
Let us compile and run the above program, this will produce the following result.
DST saving value : 5400000
Setting DST Savings for a SimpleTimeZone Instance of BST Zone
The following example shows the usage of Java SimpleTimeZone setDSTSavings() method to advance the time with respect to standard time. We've created a SimpleTimeZone using BST. Then we've advanced the time using setDSTSavings() method and printed the status using getDSTSavings() method.
package com.tutorialspoint; import java.util.Calendar; import java.util.SimpleTimeZone; public class SimpleTimeZoneDemo { public static void main( String args[] ) { // create simple time zone object SimpleTimeZone stobj = new SimpleTimeZone(-28800000, "BST", Calendar.MAY, 1,-Calendar.SUNDAY, 7200000, Calendar.OCTOBER, -1, Calendar.MONDAY, 7200000, 3600000); // setting DST saving time stobj.setDSTSavings(5400000); // checking the value System.out.println("DST saving value : " + stobj.getDSTSavings()); } }
Output
Let us compile and run the above program, this will produce the following result.
DST saving value : 5400000
To Continue Learning Please Login
Login with Google