In order to set the base time zone to GMT in Java, we use the setRawOffset(int offsetMillis) method. The java.util.TimeZone.setRawOffset(int offsetMillis) method set the base timezone offset to GMT.
Declaration − The java.util.TimeZone.setRawOffset(int offsetMillis) method is declared as follows −
public abstract void setRawOffset(int offsetMillis)
where offsetMillis is the given base time zone offset to GMT.
Let us set the base timezone offset to GMT in Java −
import java.util.*; public class Example { public static void main( String args[] ) { // creating default object of TimeZone TimeZone obj = TimeZone.getDefault(); System.out.println("Default timezone object: \n" + obj); // setting the raw offset obj.setRawOffset(25000); System.out.println("The value of the offset is :" + obj.getRawOffset()); } }
Default timezone object: sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null] The value of the offset is :25000