Java SimpleTimeZone.setRawOffset(int offsetMillis) method example

Java SimpleTimeZone.setRawOffset(int offsetMillis) method example

By technicalkeeda, Views 262, Date 28-Feb-2018

In this tutorial, You will learn how to set the GMT offset of this time zone using Java SimpleTimeZone.setRawOffset(int offsetMillis) method . It sets the base time zone offset to GMT. This is the offset to add to UTC to get local time.

tags Java

Sets the base time zone offset to GMT. This is the offset to add to UTC to get local time.

syntax

public void setRawOffset(int offsetMillis)

Parameters

offsetMillis - the given base time zone offset to GMT.

Java SimpleTimeZone setRawOffset(int offsetMillis) example

  • new SimpleTimeZone(100, "GMT"); It will construct a SimpleTimeZone with the given base time zone.
  • simpleTimeZone.setRawOffset(7200000); It will set the base time zone offset.
  • simpleTimeZone.getRawOffset(); It returns the GMT offset for this time zone.
  • Print the offset value.
package com.technicalkeeda;

import java.util.SimpleTimeZone;

public class App {

    public static void main(String[] args) {

        SimpleTimeZone simpleTimeZone = new SimpleTimeZone(100, "GMT");

        System.out.println("Initial raw offset: " + simpleTimeZone.getRawOffset());

        simpleTimeZone.setRawOffset(7200000);

        System.out.println("After setRawOffset is :- " + simpleTimeZone.getRawOffset());
    }
}

output

Initial raw offset: 100
After setRawOffset is :- 7200000

Suggested Posts

Yashwant

Yashwant

Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][gmail.com]