SimpleTimeZone setRawOffset() method in Java with Examples
The setRawOffset() method of SimpleTimeZone class is used to set the base time zone offset to GMT. The offset is added to UTC to get the local time.
Syntax:
public void setRawOffset(int offsetMillis)
Parameters: The function accepts a single parameter offsetMillis which specifies the given base time zone offset to GMT.
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:
// program to demonstrate the // function java.util.SimpleTimeZone.setRawOffset() import java.util.*; public class GFG { public static void main(String[] args) { // create simple time zone object SimpleTimeZone obj = new SimpleTimeZone(500, "GMT"); // printing RawOffset value System.out.println("Inittally RawOffset is = " + obj.getRawOffset()); // setting RawOffset on object obj obj.setRawOffset(6000000); System.out.println("RawOffset " + "set to 6000000"); // printing RawOffset value System.out.println("Current RawOffset is = " + obj.getRawOffset()); } } |
Inittally RawOffset is = 500 RawOffset set to 6000000 Current RawOffset is = 6000000
Program 2:
// program to demonstrate the // function java.util.SimpleTimeZone.setRawOffset() import java.util.*; public class GFG { public static void main(String[] args) { // create simple time zone object SimpleTimeZone obj = new SimpleTimeZone(800, "GMT"); // printing RawOffset value System.out.println("Inittally RawOffset is = " + obj.getRawOffset()); // setting RawOffset on object obj obj.setRawOffset(8000000); System.out.println("RawOffset " + "set to 8000000"); // printing RawOffset value System.out.println("Current RawOffset is = " + obj.getRawOffset()); } } |
Inittally RawOffset is = 800 RawOffset set to 8000000 Current RawOffset is = 8000000
Recommended Posts:
- TimeZone setRawOffset() Method in Java with Examples
- SimpleTimeZone clone() method in Java with Examples
- SimpleTimeZone getRawOffset() method in Java with Examples
- SimpleTimeZone hashCode() method in Java with Examples
- SimpleTimeZone setDSTSavings() method in Java with Examples
- SimpleTimeZone setStartRule(int, int, int) method in Java with Examples
- SimpleTimeZone inDaylightTime() method in Java with Examples
- SimpleTimeZone setEndRule(int, int, int) method in Java with Examples
- SimpleTimeZone toString() method in Java with Examples
- SimpleTimeZone getOffset() method in Java with Examples
- SimpleTimeZone getDSTSavings() method in Java with Examples
- SimpleTimeZone equals() method in Java with Examples
- SimpleTimeZone hasSameRules() method in Java with Examples
- SimpleTimeZone useDaylightTime() method in Java
- SimpleTimeZone setStartYear() method in Java
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.

