java.util.TimeZone.setID() Method



Description

The setID(String ID) method is used to set the time zone ID. This does not change any other data in the time zone object.

Declaration

Following is the declaration for java.util.TimeZone.setID() method.

public void setID(String ID)

Parameters

ID − This is the new time zone ID.

Return Value

NA

Exception

NA

Example

The following example shows the usage of java.util.TimeZone.setID()

package com.tutorialspoint;

import java.util.*;

public class TimeZoneDemo {
   public static void main( String args[] ) {

      // create time zone object 
      TimeZone tzone = TimeZone.getDefault();

      // set time zone ID
      tzone.setID("GMT+08:00");

      // checking time zone ID
      System.out.println("Time zone ID:" +tzone.getID());
   }    
}

Let us compile and run the above program, this will produce the following result.

Time zone ID:GMT+08:00
java_util_timezone.htm
Advertisements