TimeZone setRawOffset(int) in Java

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

Syntax:

void java.util.TimeZone.setRawOffset(int offsetMillis)

This method takes one argument. This method sets the base time zone offset to GMT. This is the offset to add to UTC to get local time.

Parameters: One parameter is required for this method.

offsetMillis: the given base time zone offset to GMT.

Exceptions: NA

Approach

Java

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

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

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

        int offsetMillis = 10000;
        timeZone.setRawOffset(offsetMillis);

        System.out.println(timeZone);
    }
}

Output:

java.util.SimpleTimeZone[id=US,offset=10000,dstSavings=3600000,useDaylight=false,startYear=0,startMode=0,startMonth=0,startDay=0,startDayOfWeek=0,startTime=0,startTimeMode=0,endMode=0,endMonth=0,endDay=0,endDayOfWeek=0,endTime=0,endTimeMode=0]


No comments:

Post a Comment