- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Set the base time zone offset to GMT in Java
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 −
Example
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:
" + obj); // setting the raw offset obj.setRawOffset(25000); System.out.println("The value of the offset is :" + obj.getRawOffset()); } }
Output
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
- Related Articles
- Get the IDs according to the given time zone offset in Java
- How to return the time-zone offset in minutes for the current locale?
- Java Program to Convert the local Time to GMT
- How to set time zone in a JSP?
- Get the default Time Zone in Java
- GMT Time in Perl
- Java Program to display Current Time in another Time Zone
- Get all the IDs of the Time Zone in Java
- Display time zone with SimpleDateFormat(“z”) in Java
- How to use time zone in a JSP?
- mysql_tzinfo_to_sql - Load the Time Zone Tables in MySQL
- Python Pandas - Convert Timestamp to another time zone
- Select current time with MySQL now() and convert it to GMT 0?
- How to handle times with a time zone in Matplotlib?
- Python Pandas - Get the UTC Offset Time

Advertisements