java.util.TimeZone.getTimeZone() Method

Advertisements


Description

The getTimeZone(String ID) method is used to get the TimeZone for the given ID.

Declaration

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

public static TimeZone getTimeZone(String ID)

Parameters

  • ID--This is the ID for a TimeZone.

Return Value

The method call returns the specified TimeZone, or the GMT zone if the given ID cannot be understood.

Exception

  • NA

Example

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

package com.tutorialspoint;

import java.util.*;

public class TimeZoneDemo {
   public static void main( String args[] ){
       
      // create time zone object     
      TimeZone timezone = TimeZone.getDefault();
      
      // checking time zone value     
      System.out.println("Time zone:" + timezone.getTimeZone("GMT-8:00"));
   }    
}

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

Time zone value:sun.util.calendar.ZoneInfo
[id="GMT-08:00",offset=-28800000,dstSavings=0,
useDaylight=false,transitions=0,lastRule=null]



Advertisements
Advertisements