TimeZone getDefault() Method in Java with Examples
Last Updated :
02 Jan, 2019
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:
import java.util.*;
public class TimeZoneDemo {
public static void main(String args[])
{
TimeZone time_zone_default
= TimeZone.getDefault();
System.out.println( "Default TimeZone: "
+ time_zone_default);
}
}
|
Output:
Default TimeZone: sun.util.calendar.ZoneInfo[id="Etc/UTC",
offset=0, dstSavings=0, useDaylight=false, transitions=0, lastRule=null]
Share your thoughts in the comments
Please Login to comment...