Java TimeZone setRawOffset() Example

TimeZone class setRawOffset() method example. This example shows you how to use setRawOffset() method.


Syntax is : public abstract void setRawOffset(int offsetMillis)
Method sets the base time zone offset to GMT. This is the offset to add to UTC to get local time.

Here is the code.
/**
 * @(#) SetRawOffsetTimeZone.java
 * A class representing use of method setRawOffset() of TimeZone
 class in java.util Package.
 * @Version  28-May-2008
 @author   Rose India Team
 */
import java.util.*;

class SetRawOffsetTimeZone {
   public static void mainString args[] ){
        // Create object of TimeZone class. 
        TimeZone obj = TimeZone.getTimeZone("America/Los_Angeles");
        // getRawOffset() method call for specified time zone.
      int offset = obj.getRawOffset();
        System.out.println("Raw Offset of this time zone is : " + offset);
    // setRawOffset() method call.
        obj.setRawOffset(7200000);
        System.out.println("#### Raw Offset set successfully !");
    offset = obj.getRawOffset();
        System.out.println("New raw Offset of this time zone is : " + offset);
  }
}

Output of the program.
Raw Offset of this time zone is : -28800000
#### Raw Offset set successfully !
New raw Offset of this time zone is : 7200000

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US