TimeZone setDefault() Method in Java with Examples Last Updated : 29 Apr, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The setDefault(TimeZone zone) method of TimeZone class in Java is used to set the TimeZone of the object that is returned by the getDefault() method of the TimeZone class. Syntax: public static void setDefault(TimeZone zone) Parameters: The method takes one parameter zone of TimeZone type which refers to the new default timezone. Return Value: The method does not return any value. Below program illustrates the working of setDefault() Method of TimeZone. Example 1: Java // Java code to illustrate setDefault() method import java.util.*; public class TimeZoneDemo { public static void main(String args[]) { // Creating an object of TimeZone class. TimeZone time_zone_default = TimeZone.getTimeZone("Europe/Rome"); time_zone_default.setDefault(time_zone_default); // Displaying the default TimeZone System.out.println("Default TimeZone: " + time_zone_default); } } Output: Default TimeZone: sun.util.calendar.ZoneInfo[id="Europe/Rome", offset=3600000, dstSavings=3600000, useDaylight=true, transitions=169, lastRule=java.util.SimpleTimeZone [id=Europe/Rome, offset=3600000, dstSavings=3600000, useDaylight=true, startYear=0, startMode=2, startMonth=2, startDay=-1, startDayOfWeek=1, startTime=3600000, startTimeMode=2, endMode=2, endMonth=9, endDay=-1, endDayOfWeek=1, endTime=3600000, endTimeMode=2]] Example 2: Java // Java code to illustrate setDefault() method import java.util.*; public class TimeZoneDemo { public static void main(String args[]) { // Creating an object of TimeZone class. TimeZone time_zone_default = TimeZone.getTimeZone("Pacific/Pago_Pago"); time_zone_default.setDefault(time_zone_default); // Displaying the default TimeZone System.out.println("Default TimeZone: " + time_zone_default); } } Output: Default TimeZone: sun.util.calendar.ZoneInfo[id="Pacific/Pago_Pago", offset=-39600000, dstSavings=0, useDaylight=false, transitions=3, lastRule=null] Reference: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#setDefault(java.util.TimeZone) Comment More infoAdvertise with us Next Article TimeUnit sleep() method in Java with Examples C chinmoy lenka Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-TimeZone +1 More Practice Tags : JavaMisc Similar Reads TimeZone setID() Method in Java with Examples The setID(String ID) method of TimeZone class in Java is used to set the time zone ID of this TimeZone. While this operation no other data of the time zone object is changed. Syntax: public void setID(String ID) Parameters: The method takes one parameter ID of String type which refers to the new ID 1 min read Clock systemDefaultZone() Method in Java with Examples java.time.Clock.systemDefaultZone() method is a static method of Clock class which returns a clock that returns the current instant of the clock using best available system clock where Zone of the returned clock is default time-zone. This method can use System.currentTimeMillis(), or other higher re 2 min read TimeUnit sleep() method in Java with Examples The sleep() method of TimeUnit Class is used to performs a Thread.sleep using this time unit. This is a convenience method that sleeps time arguments into the form required by the Thread.sleep method. Syntax: public void sleep(long timeout) throws InterruptedException Parameters: This method accepts 2 min read OffsetDateTime of() method in Java with Examples The of(int year, int month, int day, int hour, int minute, int second, int nanosecond, ZoneOffset offset) method of the OffsetDateTime class in Java is used to create an instance of OffsetDateTime from the passed values of year, month, day, hour, minute, second, nanosecond and offset. In this method 3 min read SimpleTimeZone setDSTSavings() method in Java with Examples The setDSTSavings() method of SimpleTimeZone class is used to set the amount of time that the clock is advanced during daylight saving time. The calculation is done in milliseconds. Syntax: public void setDSTSavings(int millisSavedDuringDST) Parameters: The function accepts a single parameter millis 2 min read Date setTime() method in Java with Examples The setTime() method of Java Date class sets a date object. It sets date object to represent time milliseconds after January 1, 1970 00:00:00 GMT. Syntax: public void setTime(long time) Parameters: The function accepts a single parameter time which specifies the number of milliseconds. Return Value: 2 min read Like