TimeZone setID(String) in Java

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

Syntax:

void java.util.TimeZone.setID(String ID)

This method takes one argument. This method sets the time zone ID. This does not change any other data in the time zone object.

Parameters: One parameter is required for this method.

ID: the new time zone ID.

Exceptions: NA

Approach

Java

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

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

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

        timeZone.setID("India");
        System.out.println(timeZone);
    }
}

Output:

java.util.SimpleTimeZone[id=India,offset=100,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