Java TimeZone - getRawOffset() Method
The java.util.TimeZone.getRawOffset() method returns the amount of time in milliseconds to add to UTC to get standard time in this time zone. Because this value is not affected by daylight saving time, it is called raw offset.
Syntax
public abstract int getRawOffset()
Parameters
No parameter is required.
Return Value
Returns the amount of raw offset time in milliseconds to add to UTC.
Exception
NA
Example:
In the example below, the java.util.TimeZone.getRawOffset() method is used to get the amount of time in milliseconds to add to UTC to get standard time of 'IST'.
import java.util.*; public class MyClass { public static void main(String[] args) { //creating a TimeZone object TimeZone tz = TimeZone.getTimeZone("IST"); //printing the amount of time in milliseconds //to add to UTC to get standard time of 'IST' System.out.println("Raw Offset value: " + tz.getRawOffset()); } }
The output of the above code will be:
Raw Offset value: 19800000
❮ Java.util - TimeZone