java.util.TimeZone.getDefault() Method

Advertisements


Description

The getDefault() method is used to get the default TimeZone for this host. The source of the default TimeZone may vary with implementation.

Declaration

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

public static TimeZone getDefault()

Parameters

  • NA

Return Value

The method call returns a default TimeZone.

Exception

  • NA

Example

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

package com.tutorialspoint;

import java.util.*;

public class TimeZoneDemo {
   public static void main( String args[] ){
       
      // create default time zone object
      TimeZone timezonedefault = TimeZone.getDefault();      
   
      // checking default time zone value          
      System.out.println("Default time zone is :\n" + timezonedefault);
   }    
}

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

Default time zone is :
sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,
useDaylight=false,transitions=6,lastRule=null]



Advertisements
Advertisements