📅  最后修改于: 2020-11-14 06:36:49             🧑  作者: Mango
java.util.TimeZone类表示时区偏移量,还可以计算夏令时。以下是有关TimeZone的要点-
它考虑了各个时区。
通过在此类下使用的方法,在任何国家/地区运行的程序都可以基于该特定国家/地区的时区获取TimeZone对象。
以下是java.util.TimeZone类的声明-
public abstract class TimeZone
extends Object
implements Serializable, Cloneable
以下是java.util.TimeZone类的字段-
static int LONG-这是getDisplayName()的样式说明符,用于指示长名称,例如“太平洋标准时间”。
static int SHORT-这是getDisplayName()的样式说明符,用于指示短名称,例如“ Pacific.Standard Time”。
Sr.No. | Constructor & Description |
---|---|
1 |
TimeZone() This constructor is the single constructor for invocation by subclass constructors. |
Sr.No. | Method & Description |
---|---|
1 | Object clone()
This method creates a copy of this TimeZon |
2 | static String[] getAvailableIDs()
This method gets all the available IDs supported. |
3 | static String[] getAvailableIDs(int rawOffset)
This method gets the available IDs according to the given time zone offset in milliseconds. |
4 | static TimeZone getDefault()
This method gets the default TimeZone for this host. |
5 | String getDisplayName()
This method returns a name of this time zone suitable for presentation to the user in the default locale. |
6 | String getDisplayName(boolean daylight, int style)
This method returns a name of this time zone suitable for presentation to the user in the default locale. |
7 | String getDisplayName(boolean daylight, int style, Locale locale)
This method returns a name of this time zone suitable for presentation to the user in the specified locale. |
8 | String getDisplayName(Locale locale)
This method returns a name of this time zone suitable for presentation to the user in the specified locale. |
9 | int getDSTSavings()
This method returns the amount of time to be added to local standard time to get local wall clock time. |
10 | String getID()
This method gets the ID of this time zone |
11 | abstract int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds)
This method gets the time zone offset, for current date, modified in case of daylight savings. |
12 | int getOffset(long date)
This method returns the offset of this time zone from UTC at the specified date. |
13 | abstract int getRawOffset()
This method returns the amount of time in milliseconds to add to UTC to get standard time in this time zone. |
14 | static TimeZone getTimeZone(String ID)
This method gets the TimeZone for the given ID. |
15 | boolean hasSameRules(TimeZone other)
This method returns true if this zone has the same rule and offset as another zone. |
16 | abstract boolean inDaylightTime(Date date)
This method queries if the given date is in daylight savings time in this time zone. |
17 | static void setDefault(TimeZone zone)
This method sets the TimeZone that is returned by the getDefault method. |
18 | void setID(String ID)
This method sets the time zone ID |
19 | abstract void setRawOffset(int offsetMillis)
This method sets the base time zone offset to GMT. |
20 | abstract boolean useDaylightTime()
This method queries if this time zone uses daylight savings time. |
此类从以下类继承方法-