TimeZone.getDefault() in Java

TimeZone.getDefault(): This method is available in java.util.TimeZone class of Java.

Syntax:

TimeZone java.util.TimeZone.getDefault()

This method gets the default TimeZone of the Java virtual machine.

The default TimeZone created from the ID is cached,and its clone is returned.

Parameters: NA

Returns: the default TimeZone.

Exceptions: NA

Approach

Java

import java.util.TimeZone;

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

        System.out.println(TimeZone.getDefault());
    }
}

Output:

sun.util.calendar.ZoneInfo[id="Asia/Calcutta",offset=19800000,dstSavings=0,useDaylight=false,transitions=7,lastRule=null]


No comments:

Post a Comment