TimeZone setRawOffset() Method in Java with Examples
The setRawOffset(int offsetMillis) method of TimeZone class in Java is used to set the base time zone offset to GMT. This offset value can be to UTC to get the local time.
Syntax:
public abstract void
setRawOffset(int offsetMillis)
Parameters: The method accepts a single parameter offsetMillis of Integer type which specifies the given base time zone offset to GMT.
Return Value: The method does not return any value.
Below program illustrates the above-mentioned function:
Program 1:
// Program to demonstrate the // setRawOffset() import java.util.*; public class GFG { public static void main(String[] args) { // Create time zone object TimeZone obj = TimeZone.getTimeZone("Pacific/Pago_Pago"); // Printing RawOffset value System.out.println("Initially 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()); } } |
Initially RawOffset is = -39600000 RawOffset set to 6000000 Current RawOffset is = 6000000
Program 2:
// Program to demonstrate the // setRawOffset() import java.util.*; public class GFG { public static void main(String[] args) { // Create time zone object TimeZone obj = TimeZone.getTimeZone("Europe/Rome"); // 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 = 3600000 RawOffset set to 8000000 Current RawOffset is = 8000000
Reference: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#setRawOffset(int)
Recommended Posts:
- SimpleTimeZone setRawOffset() method in Java with Examples
- TimeZone getDisplayName() Method in Java with Examples
- TimeZone getDSTSavings() Method in Java with Examples
- TimeZone setID() Method in Java with Examples
- TimeZone getOffset() Method in Java with Examples
- TimeZone inDaylightTime() method in Java with Examples
- TimeZone getTimeZone() Method in Java with Examples
- TimeZone getAvailableIDs() Method in Java with Examples
- TimeZone clone() Method in Java with Examples
- TimeZone getDefault() Method in Java with Examples
- TimeZone getOffset(int, int, int, int, int, int) Method in Java with Examples
- TimeZone observesDaylightTime() method in Java with Examples
- TimeZone hasSameRules() Method in Java with Examples
- TimeZone useDaylightTime() method in Java with Examples
- TimeZone getRawOffset() Method in Java with Examples
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.



