📌  相关文章
📜  Java.util.SimpleTimeZone类

📅  最后修改于: 2020-11-14 06:24:25             🧑  作者: Mango


介绍

java.util.SimpleTimeZone类是TimeZone的一个具体子类,代表与公历一起使用的时区。以下是有关SimpleTimeZone的要点-

  • 该类包含GMT的偏移量,称为原始偏移量。

  • 此类还保存夏令时时间表的开始和结束规则。

类声明

以下是java.util.SimpleTimeZone类的声明-

public class SimpleTimeZone
   extends TimeZone

领域

以下是java.util.SimpleTimeZone类的字段-

  • static int STANDARD_TIME-这是指定为标准时间的开始或结束时间模式的常数。

  • static int UTC_TIME-这是指定为UTC的开始或结束时间模式的常数。

  • static int WALL_TIME-这是指定为挂钟时间的开始或结束时间模式的常数。

它还包含从TimeZone类继承的字段。

类的构造函数

Sr.No. Constructor & Description
1

SimpleTimeZone(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.

2

SimpleTimeZone(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.

3

SimpleTimeZone(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.

4

SimpleTimeZone(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.

类方法

Sr.No. Method & Description
1 Object clone()

This method returns a clone of this SimpleTimeZone instance.

2 boolean equals(Object obj)

This method compares the equality of two SimpleTimeZone objects.

3 int getDSTSavings()

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

4 int 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.

5 int getOffset(long date)

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

6 int getRawOffset()

This method gets the GMT offset for this time zone.

7 inthashCode()

This method generates the hash code for the SimpleDateFormat object.

8 boolean hasSameRules(TimeZone other)

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

9 boolean inDaylightTime(Date date)

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

10 void setDSTSavings(int millisSavedDuringDST)

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

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

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

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

This method sets the daylight saving time end rule.

13 void 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.

14 void setRawOffset(int offsetMillis)

This method sets the base time zone offset to GMT.

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

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

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

This method sets the daylight saving time start rule.

17 void 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.

18 void setStartYear(int year)

This method sets the daylight saving time starting year.

19 String toString()

This method returns a string representation of this time zone.

20 boolean useDaylightTime()

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

方法继承

此类从以下类继承方法-

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