GregorianCalendar getTimeZone() in Java

getTimeZone(): This method is available in java.util.GregorianCalendar class of Java.

Syntax:

TimeZone java.util.GregorianCalendar.getTimeZone()

This method gets the time zone.

Parameters: NA

Returns: the time zone object associated with this calendar.

Exceptions: NA

Approach

Java

import java.util.GregorianCalendar;

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

        GregorianCalendar cal = new GregorianCalendar();

        System.out.println(cal.getTimeZone());
    }
}

Output:

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


No comments:

Post a Comment