SimpleTimeZone getOffset(long) in Java

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

Syntax:

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

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

Parameters: One parameter is required for this method.

date: the time at which the time zone offset is found.

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

Exceptions: NA

Approach

Java

import java.util.SimpleTimeZone;

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

        SimpleTimeZone simpleTimeZone =
new SimpleTimeZone(100, "India");

        long date = 10000010L;

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

Output:

100


No comments:

Post a Comment