Java.util.TimeZone Class
Java TimeZone Class
Java.util package provides a TimeZone class which represents a time zone offset, and also figures out daylight savings. It takes into consideration various time zone. Through the method used under this class a program running in any country, gets a TimeZone object based on that particular country's time zone.
Class declaration
The declaration of java.util.TimeZone class is:
public abstract class TimeZone extends Object implements Serializable, Cloneable
Fields
S.N | Field and Description |
---|---|
1. |
static int LONG A style specifier for getDisplayName() indicating a long name, such as "Pacific Standard Time." |
2. |
static int SHORT A style specifier for getDisplayName() indicating a short name, such as "PST." |
Class Constructor
S.N | Constructors & Description |
---|---|
1. |
TimeZone() Sole constructor. |
java.util.TimeZone Methods
The java.util.TimeZone class has a number of methods which are listed below:
Member Methods
S.N | Methods & Description |
---|---|
1. |
Object clone() Creates a copy of this TimeZone. |
2. |
static String[] getAvailableIDs() Gets all the available IDs supported. |
3. |
static String[] getAvailableIDs(int rawOffset) Gets the available IDs according to the given time zone offset in milliseconds. |
4. |
static TimeZone getDefault() Gets the default TimeZone of the Java virtual machine. |
5. |
String getDisplayName() Returns a long standard time name of this TimeZone suitable for presentation to the user in the default locale. |
6. |
String getDisplayName(boolean daylight, int style) Returns a name in the specified style of this TimeZone suitable for presentation to the user in the default locale. |
7. |
String getDisplayName(boolean daylight, int style, Locale locale) Returns a name in the specified style of this TimeZone suitable for presentation to the user in the specified locale. |
8. |
String getDisplayName(Locale locale) Returns a long standard time name of this TimeZone suitable for presentation to the user in the specified locale. |
9. |
int getDSTSavings() Returns the amount of time to be added to local standard time to get local wall clock time. |
10. |
String getID() Gets the ID of this time zone. |
11. |
int getOffset(long date) Returns the offset of this time zone from UTC at the specified date. |
12. |
abstract int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds) Gets the time zone offset, for current date, modified in case of daylight savings. |
13. |
abstract int getRawOffset() 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) Gets the TimeZone for the given ID. |
15. |
static TimeZone getTimeZone(ZoneId zoneId) Gets the TimeZone for the given zoneId. |
16. |
boolean hasSameRules(TimeZone other) Returns true if this zone has the same rule and offset as another zone. |
17. |
abstract boolean inDaylightTime(Date date) Queries if the given date is in Daylight Saving Time in this time zone. |
18. |
boolean observesDaylightTime() Returns true if this TimeZone is currently in Daylight Saving Time, or if a transition from Standard Time to Daylight Saving Time occurs at any future time. |
19. |
static void setDefault(TimeZone zone) Sets the TimeZone that is returned by the getDefault method. |
20. |
void setID(String ID) Sets the time zone ID. |
21. |
abstract void setRawOffset(int offsetMillis) Sets the base time zone offset to GMT. |
22. |
ZoneId toZoneId() Converts this TimeZone object to a ZoneId. |
23. |
abstract boolean useDaylightTime() Queries if this TimeZone uses Daylight Saving Time. |
Methods inherited
This class inherits the methods of following class:
- java.lang.Object