Java Utility Library

Java TimeZone - setRawOffset() Method



The java.util.TimeZone.setRawOffset() method is used to set the base time zone offset to GMT. This is the offset to add to UTC to get local time.

Syntax

public abstract void setRawOffset(int offsetMillis)

Parameters

offsetMillis Specify the given base time zone offset to GMT.

Return Value

void type.

Exception

NA

Example:

In the example below, the java.util.TimeZone.setRawOffset() method is used to set the base time zone offset to GMT.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //creating a TimeZone object
    TimeZone tz = TimeZone.getDefault();
   
    //setting the raw offset
    tz.setRawOffset(1000);

    //printing the raw offset value
    System.out.println("Raw Offset value: " + tz.getRawOffset());
  }
}

The output of the above code will be:

Raw Offset value: 1000

❮ Java.util - TimeZone