TimeZone getDefault() Method in Java with Examples

The getDefault() method of TimeZone class in Java is used to know the default TimeZone for this system or host. This may vary in according to the implementation in different environment.

Syntax:

public static TimeZone getDefault()

Parameters: The method does not take any parameters.

Return Value: The method returns the default TimeZone of the host.

Below program illustrates the working of getDefault() Method of TimeZone:

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java code to illustrate getDefault() method
  
import java.util.*;
  
public class TimeZoneDemo {
    public static void main(String args[])
    {
        // Creating an object of TimeZone class.
        TimeZone time_zone_default
            = TimeZone.getDefault();
  
        // Displaying the default TimeZone
        System.out.println("Default TimeZone: "
                           + time_zone_default);
    }
}

chevron_right


Output:

Default TimeZone: sun.util.calendar.ZoneInfo[id="Etc/UTC",
offset=0, dstSavings=0, useDaylight=false, transitions=0, lastRule=null]


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.