Java.util.SimpleTimeZone Class

Java.util.SimpleTimeZone Class

Introduction

The java.util.SimpleTimeZone class is a concrete subclass of TimeZone that represents a time zone for use with a Gregorian calendar.Following are the important points about SimpleTimeZone:

  • The class holds an offset from GMT, called raw offset.
  • This class also holds start and end rules for a daylight saving time schedule.

Class declaration

Following is the declaration for java.util.SimpleTimeZone class:

public class SimpleTimeZone
   extends TimeZone

Field

Following are the fields for java.util.SimpleTimeZone class:

  • static int STANDARD_TIME — This is the constant for a mode of start or end time specified as standard time.
  • static int UTC_TIME — This is the constant for a mode of start or end time specified as UTC.
  • static int WALL_TIME — This is the constant for a mode of start or end time specified as wall clock time.

It also consists of fields inherited from class TimeZone.

Class constructors

S.N.Constructor & Description
1SimpleTimeZone(int rawOffset, String ID)

This constructs a SimpleTimeZone with the given base time zone offset from GMT and time zone ID with no daylight saving time schedule.

2SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime)

This constructs a SimpleTimeZone with the given base time zone offset from GMT, time zone ID, and rules for starting and ending the daylight time.

3SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime, int dstSavings)

This constructs a SimpleTimeZone with the given base time zone offset from GMT, time zone ID, and rules for starting and ending the daylight time.

4SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int startTimeMode, int endMonth, int endDay, int endDayOfWeek, int endTime, int endTimeMode, int dstSavings)

This constructs a SimpleTimeZone with the given base time zone offset from GMT, time zone ID, and rules for starting and ending the daylight time.

Class methods

S.N.Method & Description
1Object clone()

This method returns a clone of this SimpleTimeZone instance.

2boolean equals(Object obj)

This method compares the equality of two SimpleTimeZone objects.

3int getDSTSavings()

This method returns the amount of time in milliseconds that the clock is advanced during daylight saving time.

4int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)

This method returns the difference in milliseconds between local time and UTC, taking into account both the raw offset and the effect of daylight saving, for the specified date and time.

5int getOffset(long date)

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

6int getRawOffset()

This method gets the GMT offset for this time zone.

7int hashCode()

This method generates the hash code for the SimpleDateFormat object.

8boolean hasSameRules(TimeZone other)

This method returns true if this zone has the same rules and offset as another zone.

9boolean inDaylightTime(Date date)

This method queries if the given date is in daylight saving time.

10void setDSTSavings(int millisSavedDuringDST)

This method sets the amount of time in milliseconds that the clock is advanced during daylight saving time.

11void setEndRule(int endMonth, int endDay, int endTime)

This method sets the daylight saving time end rule to a fixed date within a month.

12void setEndRule(int endMonth, int endDay, int endDayOfWeek, int endTime)

This method sets the daylight saving time end rule.

13void setEndRule(int endMonth, int endDay, int endDayOfWeek, int endTime, boolean after)

This method sets the daylight saving time end rule to a weekday before or after the given date within a month, e.g., the first Monday on or after the 8th.

14void setRawOffset(int offsetMillis)

This method sets the base time zone offset to GMT.

15void setStartRule(int startMonth, int startDay, int startTime)

This method Sets the daylight saving time start rule to a fixed date within a month.

16void setStartRule(int startMonth, int startDay, int startDayOfWeek, int startTime)

This method sets the daylight saving time start rule.

17void setStartRule(int startMonth, int startDay, int startDayOfWeek, int startTime, boolean after)

This method Sets the daylight saving time start rule to a weekday before or after the given date within a month, e.g., the first Monday on or after the 8th.

18void setStartYear(int year)

This method sets the daylight saving time starting year.

19String toString()

This method returns a string representation of this time zone.

20boolean useDaylightTime()

This method queries if this time zone uses daylight saving time.

Methods inherited

This class inherits methods from the following classes:

  • java.util.TimeZone
  • java.util.Object

Was this article helpful?

Related Articles

Leave A Comment?

You must be logged in to post a comment.