TimeZone getOffset(long) in Java

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

Syntax:

int java.util.TimeZone.getOffset(long date)

This method takes one argument. This method returns the offset of this time zone from UTC at the specified date.

Parameters: One parameter is required for this method.

date: the date represented in milliseconds since January 1, 1970, 00:00:00 GMT.

Returns: the amount of time in milliseconds to add to UTC to get local time.

Exceptions: NA

Approach

Java

import java.util.SimpleTimeZone;
import java.util.TimeZone;

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

        TimeZone timeZone = new SimpleTimeZone(100, "US");

        long date = 10000010L;

        System.out.println(timeZone.getOffset(date));
    }
}

Output:

100


No comments:

Post a Comment